Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97110 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56071 invoked from network); 21 Nov 2016 18:09:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2016 18:09:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.89 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.89 mx108.easyname.com Received: from [77.244.243.89] ([77.244.243.89:35412] helo=mx204.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AB/F1-40890-D5833385 for ; Mon, 21 Nov 2016 13:09:34 -0500 Received: from cable-81-173-133-127.netcologne.de ([81.173.133.127] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1c8t22-0001tl-Bs; Mon, 21 Nov 2016 18:09:30 +0000 Reply-To: internals@lists.php.net References: To: Niklas Keller , PHP Internals , daniel@honestempire.com, Christoph Becker Message-ID: <7ee57e10-3877-3d76-21bf-30253728f3d5@fleshgrinder.com> Date: Mon, 21 Nov 2016 19:09:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] Parameter No Type Variance From: php@fleshgrinder.com (Fleshgrinder) On 11/21/2016 10:39 AM, Niklas Keller wrote: > Morning Internals, > > I'd like to announce a RFC to allow omitting the type declarations for > parameters in subclasses: > https://wiki.php.net/rfc/parameter-no-type-variance > > PHP doesn't currently allow variance for parameters as checking these for > compatibility isn't possible on compile time. > This limitation is caused by autoloading and doesn't allow widening the > accepted parameters. > > This RFC proposes to allow ommiting the type entirely in a subclass, as > dropping all parameter constraints is > always valid according to the LSP principle. > > We already allow return types being added in subclasses. > > Your feedback is welcome. :-) > > Regards, Niklas > I think that this is a good proposal. @Daniel Morris: an Interface is just a fully abstract class, no special casing is necessary. Every definition is a contract and every definition adheres to certain rules. In this case LSP applies. I do not think that it is necessary to add any special keyword as proposed by @Christoph Becker since nothing means mixed and mixed means anything, thus, it actually already is a special keyword. However, I do not think that this is the solution for type variance in general since type checking is now up to userland which means lots of repetition. Actual type checks are of arguments are also performed at runtime, same could be done for type variance checks. Pretty much the same as with _type erasure_ vs. _type reification_. Having a runtime check is better than having none at all. We will probably want this anyways in PHP since we want Generics that are type safe at runtime. At least I hope we do. ;) Note that implementing this would also allow your proposal to work. This goes back to what I said before. No restriction is mixed which is the parent of anything, this is true a runtime too. -- Richard "Fleshgrinder" Fussenegger