Bug #66249 [NEW]: empty() returns true, when it shouldn't on an object
| From: | kenyon dot jh at gmail dot com | Date: | Mon, 09 Dec 2013 20:32:37 +0000 |
| Subject: | Bug #66249 [NEW]: empty() returns true, when it shouldn't on an object | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-183205@lists.php.net to get a copy of this message | ||
From: kenyon dot jh at gmail dot com
Operating system: Debian
PHP version: 5.4.22
Package: Class/Object related
Bug Type: Bug
Bug description:empty() returns true, when it shouldn't on an object
Description:
------------
My PHP version wasn't an option, so it is actually "PHP Version
5.4.4-14+deb7u5" and my system is Linux toshiba 3.2.0-4-amd64 #1 SMP
Debian 3.2.51-1 x86_64
Basically, when referencing an variable through a class (I only tested
with __set and __get) it empty() returns true, even when it should
return false.
Since it is kind of hard to explain, I posted a script below that
demonstrates what I am talking about.
Test script:
---------------
<?php
class testing {
protected $_response = array();
public function __set($key, $value) {
$this->_response[$key] = $value;
}
public function __get($key) {
return $this->_response[$key];
}
}
$testing = new testing();
$testing->foo = 'bar';
var_dump($testing->foo); //Returns 'string(3) "bar"
var_dump(empty($testing->foo)); //Returns bool(true)
?>
Expected result:
----------------
Line 17 should return bool(false)
Actual result:
--------------
Line 17 actually returns bool(true)
--
Edit bug report at https://bugs.php.net/bug.php?id=66249&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66249&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66249&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66249&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66249&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66249&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66249&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66249&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66249&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66249&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66249&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66249&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66249&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66249&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66249&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66249&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66249&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66249&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66249&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66249&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66249&r=mysqlcfg