Re: [RFC] Always generate fatal error for incompatible method signatures

From: Date: Tue, 09 Apr 2019 15:35:24 +0000
Subject: Re: [RFC] Always generate fatal error for incompatible method signatures
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-105180@lists.php.net to get a copy of this message
On Tue, Apr 9, 2019 at 9:00 AM Gabriel O <gadelat@gmail.com> wrote: > > I believe rfc deals with reverse situation > > On 9 April 2019 4:47:50 PM Dan Ackroyd <Danack@basereality.com> wrote: > > > On Tue, 9 Apr 2019 at 11:58, Gabriel O <gadelat@gmail.com> wrote: > > > >> And this RFC conveniently shows only big LSP violation examples like array > >> -> int, but not widely used narrowing like mixed/object -> specific instance. > > > > > > Type narrowing or contravariant parameters is properly supported for > > PHP 7.4: > > > > https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters > > , which is why this RFC doesn't need to cover them. > > > > cheers > > Dan > > Ack If you want the reverse to be true, then your code has bugs waiting to show themselves. The earlier we can catch these bugs, the better. One thing to note is that return type information does permit optimizations in some cases. For instance, I believe if a private method has a return type constraint of int, then the optimizer can rule out certain edge cases, and in some cases use type specialized handlers. We can do these sorts of optimizations in more places if the LSP issues are always errors, instead of warnings. So for both correctness and performance, I support this change.

« previous php.internals (#105180) next »