On 5/26/2016 12:03 PM, Rowan Collins wrote: > Could you summarise what your proposal actually is; I got a bit lost > with what your long list of examples was trying to show me. >
To summarize it: we should change the behavior of isset() to work exactly the same way as it does for associative array keys if they have null assigned to them. Shorter example of current PHP implementation: $a = ['x' => null]; var_dump(isset($a['x'])); // false var_dump(array_key_exists($a, 'x')); // true $o = (object) ['x' => null]; var_dump(isset($a->x)); // true var_dump(property_exists($a, 'x')); // true PHP 8 $o = (object) ['x' => null]; var_dump(isset($a->x)); // false var_dump(property_exists($a, 'x')); // true This would actually be more consistent with the isset() behavior together with associative arrays and it would allow us to handle typed properties that where not initialized (as illustrated in the longer example). On 5/26/2016 12:03 PM, Rowan Collins wrote: > Can you provide a reference for that? The only thing mentioned in the > changelog in the manual is this rather rare situation: > > $foo = 'a string'; > isset($foo['some_key']); > > $foo['some_key'] doesn't actually have much of a meaning in that case, > anyway, and it has nothing to do with initialisation. > Just tested it with those ancient versions and you are right that I interpreted that sentence incorrectly. The behavior of isset() with array keys that were explicitly set to null never changed. ref: https://3v4l.org/TS621 However, this does not change my proposal. :) -- Richard "Fleshgrinder" Fussenegger
signature.asc
Description: OpenPGP digital signature