Re: [RFC] Alternative typehinting syntax for accessors

From: Date: Sat, 05 Jan 2013 00:48:14 +0000
Subject: Re: [RFC] Alternative typehinting syntax for accessors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-64537@lists.php.net to get a copy of this message
On Sat, Jan 5, 2013 at 12:31 AM, Steve Clay <steve@mrclay.org> wrote: > Would the following two be exactly functionally equivalent? > > public Foo $foo; > > public $foo { > get; > set(Foo $value) { $this->foo = $value; } > } > > We should also consider how an author would allow type-hinted properties > to accept NULL as a new value, in both proposals. > I think that's a very interesting question, thanks for bringing it up. I think a good approach here would be the same one used for function argument typehints, i.e. allow NULL when NULL is specified as the default value. So public DateTime $date; would not allow an explicit NULL assignment, whereas public DateTime $date = NULL; would. Nikita

« previous php.internals (#64537) next »