ID: 29234 Comment by: info at peter-thomassen dot de Reported By: chrissy at codegoat dot com Status: No Feedback Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 5.0.0 New Comment:
The problem still exists with 5.1.4. Previous Comments: ------------------------------------------------------------------------ [2005-03-14 01:00:14] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2005-03-06 20:49:52] [EMAIL PROTECTED] 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 ------------------------------------------------------------------------ [2004-07-20 19:34:48] benjcarson at digitaljunkies dot ca This may be related to bug #28176. ------------------------------------------------------------------------ [2004-07-18 01:14:15] chrissy at codegoat dot com Description: ------------ The code below has a class with two properties. One which is a regular public class property and the other which is accessed through the __get function. Both are set to "Not Empty". However, when you call empty() on the one accessed through __get, the empty() function returns TRUE which is incorrect. The problem can be remedied by first assigning the value of the property to a variable and then calling the empty function on that variable. Reproduce code: --------------- <?php class EmptyTest { public $emptyTest1 = "Not Empty"; protected $properties = array ('emptyTest2' => "Not Empty"); function __get($key) { if (array_key_exists($key, $this->properties)) return $this->properties[$key]; } } $emptyTest = new EmptyTest(); echo "The value of Test 1 is: \"" . $emptyTest->emptyTest1 . "\"<br/>The value of Test 2 is: \"" . $emptyTest->emptyTest2 . "\"<br/>-----------------------------------------------<br/><br/>"; if (empty($emptyTest->emptyTest1)) echo "Test 1 was empty <br/>"; else echo "Test 1 was not empty <br/>"; if (empty($emptyTest->emptyTest2))echo "Test 2 was empty <br/>"; else echo "Test 2 was not empty <br/>"; $test = $emptyTest->emptyTest2; if (empty($test))echo "Test 2 was empty this time<br/>"; else echo "Test 2 was not empty this time<br/>"; ?> Expected result: ---------------- Both emptyTest1 and emptyTest2, when passed to the empty function, the function should return true. It could be that calling empty with a property that has had its access overloaded by the __get function is invalid. If this is the case, I would assume empty should at least throw a Warning. Actual result: -------------- The output of the above program is... The value of Test 1 is: "Not Empty" The value of Test 2 is: "Not Empty" ----------------------------------------------- Test 1 was not empty Test 2 was empty Test 2 was not empty this time ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29234&edit=1