On Mon, Jan 21, 2013 at 7:54 PM, Gustavo Lopes <glo...@nebm.ist.utl.pt>wrote:

> * It's a promise that's not guaranteed. As long as the getter is allowed
> to reference the value of the variable can arbitrarily be changed to
> whatever type. It may also be possible to do the same with unserialization.
>

Yes, that's a good point. One can't see this proposal as an introduction of
strict typing, that fully guarantees that the property has one type and one
type only. The typehints are there to help the programmer find mistakes. If
he assigns a wrong type, then he'll get an error. But yes, it will break
down if he actively tries to work against the system. If you start
modifying unserialization input and stuff like that, you will be able to
work around this. Just like you can also work around the method typehints
if you feel like it. I still find them useful.


> * The benefits are minimal. The only real benefit is cutting maybe two
> lines of code in an indisputably common scenario.
>

It's not just about the lines of code. It's about having a more readable
and more intuitive syntax. Am I the only one who thinks that "public $date
{ get; set(DateTime $date); }" looks pretty ugly/unclear compared to
"public DateTime $date;"?

Thanks,
Nikita

Reply via email to