From: Operating system: WIN PHP version: 5.3.3 Package: Class/Object related Bug Type: Bug Bug description:__set() ignores setting properties with empty names
Description: ------------ Within only __set(), you can set a value of a new property with an empty name ($p = null; $this->$p = 1;). The property won't really be created though - the effects will be invisible to the user. No errors, warnings, or notices are generated. This lack of an error message might cause difficult to pinpoint bugs since all assignments of previously undeclared properties within object scope regardless of originating method are routed through __set(); Elsewhere in the object, attempting this will cause a fatal 'Cannot access empty property' error as expected. Test script: --------------- <?php class A{ function __set($prop, $val) { echo "SET $prop = $val\n"; $this->$prop = $val; // should've caused error } } $a = new A(); $prop = null; $a->$prop = 2; print_r($a); // empty object ?> Expected result: ---------------- fatal 'Cannot set empty property' or 'invalid property name' error. Actual result: -------------- Nothing. -- Edit bug report at http://bugs.php.net/bug.php?id=52484&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52484&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52484&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52484&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52484&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52484&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52484&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52484&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52484&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52484&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52484&r=support Expected behavior: http://bugs.php.net/fix.php?id=52484&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52484&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52484&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52484&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52484&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52484&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52484&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52484&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52484&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52484&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52484&r=mysqlcfg