Re: [RFC] Alternative typehinting syntax for accessors

From: Date: Fri, 04 Jan 2013 15:19:07 +0000
Subject: Re: [RFC] Alternative typehinting syntax for accessors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-64523@lists.php.net to get a copy of this message
This shouldn't be an issue because it is not possible to set the property without going through the setter, which would be a type hinted accessor function.

Ergo, an attempt to set the value to an invalid value would cause a fatal error and thus the setter would not be able to then set it to the invalid value.


On 1/4/2013 9:15 AM, Levi Morrison wrote:
This proposal looks really good to me. It cuts out a lot of syntax and boilerplate for a commonly used case. However, there is one issue that I know somebody is going to raise: Argument: If you change the value of the property without using the setter then get could return something that has a type mismatch with the type-hint. If I understand the current RFC for properties correctly, the only place that a property can be directly written to without the accessor is inside of the __setProperty method. This almost nullifies the argument completely. The only other place for possible error would be assigning a value in the constructor that does not match the type-hint. However, because we adding a new syntax we *could* disallow assigning a value if it really was that problematic. I do not personally feel that would be necessary. I feel that this argument is not weighty enough to stop the proposal for this improved syntax.
-- -Clint

Thread (47 messages)

« previous php.internals (#64523) next »