Re: PHP7 and types

From: Date: Sat, 11 Jul 2015 19:25:18 +0000
Subject: Re: PHP7 and types
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-87112@lists.php.net to get a copy of this message
On Sat, Jul 11, 2015 at 12:41 PM, Sebastian Bergmann <sebastian@php.net> wrote: > Am 11.07.2015 um 19:53 schrieb S.A.N: > > It will be useful for autocomplete in IDE > > That argument is bogus since proper IDEs (PhpStorm, fex.) leverage > docblock annotations for that already. > > Agreed. I don't know any IDE meant for PHP that doesn't respect docblock declarations. I think the benefit comes more in being able to make a property public, and still have control over its type. Currently the only way to do it is to have your property be private and use public get/set method(s) instead. IE: class foo { public int $bar; } -- vs. -- class foo { private $bar = 0; public function getBar() : int { return $this->bar; } public function setBar(int $val) { $this->bar = $val; } } Granted its still far less verbose for scalar types than in the current 5.x world where you have to have your own type checks as well. -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.internals (#87112) next »