From: luke at qcm dot cz
Operating system: irelevant (tested on linux)
PHP version: 5.0.4
PHP Bug Type: SPL related
Bug description: empty function with SPL
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 bug report at http://bugs.php.net/?id=34182&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34182&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34182&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34182&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34182&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34182&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34182&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34182&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34182&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34182&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34182&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34182&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34182&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34182&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34182&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34182&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34182&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34182&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34182&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34182&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34182&r=mysqlcfg