Re: Array dereferencing of scalars

From: Date: Tue, 09 Jun 2015 12:35:20 +0000
Subject: Re: Array dereferencing of scalars
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-86518@lists.php.net to get a copy of this message
Matt Wilmas wrote: > Forgetting the NULL case for a sec... With: > > $v = []; > $v[0][1][2][3][4][5][6][7][8][9]; > > How/why are we going from 1 Notice to 10?! > > With: > > unset($v); > $v[0]; > > Why from 1 Notice about the undefined variable, to 2? That's totally > new, and it really doesn't make sense to make any more noise after > you've already been told about the variable. (Same after the first > undefined array offset, too, but this makes the point more obvious.) > > That's why I'm saying, you can only really change it for non-NULL > scalars that have an actual value, to keep this other stuff the same, > and sane. > > I don't really see a semantic issue with the NULL case, either, unlike > other scalar types. Current behavior: <?php $v = NULL; echo $v->foo->bar; ?> Notice: Trying to get property of non-object in %s on line %d Notice: Trying to get property of non-object in %s on line %d So trying to access a property on NULL gives a notice, but trying to access an element of NULL shouldn't? Also note, that chained property access raises multiple notices. -- Christoph M. Becker

« previous php.internals (#86518) next »