[PR 614] ArrayObject and isset() / empty() behaviour

From: Date: Fri, 07 Mar 2014 10:14:18 +0000
Subject: [PR 614] ArrayObject and isset() / empty() behaviour
Groups: php.internals 
Request: Send a blank email to internals+get-72989@lists.php.net to get a copy of this message
Hi, I come across the following bug: https://bugs.php.net/bug.php?id=66834 With an extended ArrayObject instance, the behaviour of isset() and empty() is as follows: 1. Call static::offsetExists() 2. If return value is truthy, then a. isset() returns true b. empty() returns false c. spl_array_has_property() returns true However, if the ArrayObject instance is not overridden: 1. Fetch value (either via string or long key) 2. If key is found, then: a. isset() returns false if value is null, true otherwise. b. empty() returns true if value is truty, false otherwise. c. spl_array_has_property() returns true That's counterintuitive, so my patch addresses this by also calling offsetGet() if applicable. I wanted to bring this to the attention of the group first, because it may affect performance to achieve this goal: https://github.com/php/php-src/pull/614 I've tried to contact Marcus Boerger, but I was told that he's been less active lately. Let me know your thoughts. The patch targets 5.4 onwards. -- -- Tjerk

« previous php.internals (#72989) next »