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
>
>
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
>
>