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

From: Date: Fri, 07 Mar 2014 14:15:33 +0000
Subject: Re: [PR 614] ArrayObject and isset() / empty() behaviour
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-72991@lists.php.net to get a copy of this message
On Fri, Mar 7, 2014 at 11:14 AM, Tjerk Meesters <tjerk.meesters@gmail.com> wrote: > 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. You should try to contact Etienne Kneuss, he'll be able to help. He is often available on IRC. Julien

« previous php.internals (#72991) next »