On 19/09/2018 21:04, Levi Morrison wrote:
I think this code should be allowed:
class User {
public int $id;
public string $preferred_name;
public string $username;
}
Why? What contract is being enforced by that class that is not enforced
by this class?
class User {
public ?int $id=null;
public ?string $preferred_name=null;
public ?string $username=null;
}
Both require the consumer of the class to trust that someone, somewhere, has
initialised the fields (and not subsequently unset them).
Or have I misunderstood what you intended with that example?
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php