Req #73242 [NEW]: empty($obj->protectedPropery) does not __get the property value

From: Date: Tue, 04 Oct 2016 14:24:05 +0000
Subject: Req #73242 [NEW]: empty($obj->protectedPropery) does not __get the property value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204443@lists.php.net to get a copy of this message
From: touzfik10 at gmail dot com Operating system: windows PHP version: 7.0.11 Package: Class/Object related Bug Type: Feature/Change Request Bug description:empty($obj->protectedPropery) does not __get the property value Description: ------------ I think empty($expression) is supposed to evaluate $expression before it checks if it is empty. In the code bellow, empty($obj->protectedProperty) is supposed to call __get before checking if it's empty. That makes sense, right? Well, I don't think it's happening. Sorry if I am missing something. But I think this behavior should change. Test script: --------------- $fooList = [ new Foo, new Foo ]; $bar = new Bar($fooList); var_dump(empty($bar->fooList)); // true $fooList = $bar->fooList; var_dump(empty($fooList)); // false class Foo { } class Bar { protected $fooList = []; public function __construct(array $fooList) { $this->fooList = $fooList; } public function __get(string $property) { return $this->$property; } } -- Edit bug report at https://bugs.php.net/bug.php?id=73242&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73242&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73242&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73242&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73242&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73242&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73242&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73242&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73242&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73242&r=support Expected behavior: https://bugs.php.net/fix.php?id=73242&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73242&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73242&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73242&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73242&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73242&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73242&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73242&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73242&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73242&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73242&r=mysqlcfg

« previous php.bugs (#204443) next »