On 5/26/16, 12:30 PM, "Fleshgrinder" <p...@fleshgrinder.com> wrote:
>The problem is a completely different one, how should the following code >behave? > > class A { > > public int $x; > > } > > (new A)->x; > >The property has no value assigned but it is being accessed. The current >PHP behavior is to simply initialize it with null. But this is >impossible according to the type definition. > >There are not many ways to handle this. I think we already had all of >them proposed: > >0. Fatal error after __construct was called. >1. Fatal error and abort. >2. Initialize with appropriate type. >3. Initialize with null. Under another 5th option, the problem you state does not arise. Disallow "public int $x;". Under this option you may declare $x with type int and an initial value or you may declare $x without type but you may not declare $x with type (nullable or not) and undefined initial value. Tom -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php