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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php