Re: [RFC Discussion] Typed Properties

From: Date: Wed, 16 Mar 2016 18:58:26 +0000
Subject: Re: [RFC Discussion] Typed Properties
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-91708@lists.php.net to get a copy of this message
class SomeStruct{ public int $a; } class Joe { public SomeStruct $struct; function test1() : SomeStruct{ return new SomeStruct(); // TypeError: can't return a type whose fields' type declarations aren't fulfilled } function test2(SomeStruct $struct){ // TypeError: can't pass in a type whose fields' type declarations aren't fulfilled [*] } function test3(){ $this->struct = new SomeStruct(); // TypeError: can't assign to a typed field a type whose fields' type declarations aren't fulfilled } } (new Joe)->test2(new SomeStruct()); // [*] 2016-03-16 19:41 GMT+01:00 Johannes Schlüter <johannes@schlueters.de>: > On Wed, 2016-03-16 at 19:15 +0100, Bob Weinand wrote: > > > > Eih, only to typed properties. Everything else would be insane ;-) > > Sorry for being imprecise. > > Ok, quite a lot better, but still weird difference to the language. > > > There's a notable amount of places where references are being used and > often users aren't aware. (Binding parameters in database queries, in > order to support OUT parameters, comes to mind, many array functions > take an array, some functions use it to report error codes, ...) > > I guess this will be a famous support issue. > > And yeah, I'd love to "fix" all those places and get rid of the > references, but BC ... it's quite massive :-) > > > johannes >

« previous php.internals (#91708) next »