#34182 [Opn->Fbk]: empty function with SPL
| From: | tony2001@php.net | Date: | Thu, 18 Aug 2005 08:41:41 +0000 |
| Subject: | #34182 [Opn->Fbk]: empty function with SPL | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-83749@lists.php.net to get a copy of this message | ||
ID: 34182
Updated by: tony2001@php.net
Reported By: luke at qcm dot cz
-Status: Open
+Status: Feedback
Bug Type: SPL related
Operating System: irelevant (tested on linux)
PHP Version: 5.0.4
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-08-18 10:21:25] luke at qcm dot cz
Description:
------------
caling empty function with SPL object attribute (arrayaccess) as
parameter return always false (is not empty).
Reproduce code:
---------------
class a implements ArrayAccess {
private $vars;
public function offsetExists($offset) {
return (isset($this->vars[$offset]));
} // offsetExists
public function offsetGet($offset) {
return $this->vars[$offset];
} // offsetGet
public function offsetSet($offset, $value) {
$this->vars[$offset] = $value;
} // offsetSet
public function offsetUnset($offset) {
if ($this->offsetExists($offset)) {
unset($this->vars[$offset]);
} // if
} // offsetUnset
}
$x = new a();
$x['key'] = '';
var_dump($x['key']);
var_dump(empty($x['key']));
$y = $x['key'];
var_dump($y);
var_dump(empty($y));
Expected result:
----------------
string(0) "" bool(true) string(0) "" bool(true)
Actual result:
--------------
string(0) "" bool(false) string(0) "" bool(true)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34182&edit=1