Re: Allowing static as a return type

From: Date: Tue, 01 Mar 2016 17:31:53 +0000
Subject: Re: Allowing static as a return type
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-91469@lists.php.net to get a copy of this message
The reason is probably that return types are currently invariant, so a inheriting class would have to declare the parent as return type anyway. Lee Davis <leedavis81@gmail.com> schrieb am Di., 1. März 2016 12:46: > Hi Internals, > > whilst recently playing with return type hints on PHP 7 I noticed that > "static" cannot be used as a valid return type. I'm not entirely sure > whether this has been purposely prevented or not. > > https://3v4l.org/LEXis > > The behaviour works it's just a parse error that's stopping it. It's fairly > easy to get around this behaviour by using 'self' on the return hint > however I'm not too sure how correct this is considering you might want to > have that method be extendable. > > https://3v4l.org/rk4W6 > > I always considered 'self' to represent the class where the definition > lies, and 'static' to mean the caller class (i.e. when using LSB) so it > might be something that you'd want to define on the type hint. > > Do you think this is something we should allow into the type system? > > Thoughts? >

« previous php.internals (#91469) next »