From: ken at gizzar dot com Operating system: Mac OS X PHP version: 5.3CVS-2008-03-17 (snap) PHP Bug Type: Scripting Engine problem Bug description: Late static binding not available for static properties
Description: ------------ Late static binding not available for static properties. A very critical use case for PHP 5.3's late static binding is the ActiveRecord pattern. An example implementation would have the ActiveRecord abstract class to dynamically create objects of found records. The metadata about each table should be kept with each ActiveRecord class's static scope. This is simply not doable even with the new late static binding functionality of PHP 5.3. Basically the same question as #44315, but it's really a design flaw in the PHP 5.3 scripting engine to not include a way for the parent class to dynamically create static properties. If the resolution is "no fix," then I'll be forced to create a metadata static variable which is (namespaced and) shared by all the classes extending the AR class. Reproduce code: --------------- <?php class P { public static $v = "parent"; public static function foo() { static::$v = "child"; echo static::$v . "\n"; } } class C extends P { } echo P::$v . "\n"; C::foo(); echo P::$v . "\n"; // RESULTS parent child child Expected result: ---------------- // RESULTS: foo() creates a static property for the child class and sets it according to the static:: scope parent child parent Actual result: -------------- // RESULTS: static:: only respects the static property in the parent P class parent child child -- Edit bug report at http://bugs.php.net/?id=44457&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44457&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44457&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44457&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44457&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44457&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44457&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44457&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44457&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44457&r=support Expected behavior: http://bugs.php.net/fix.php?id=44457&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44457&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44457&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44457&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44457&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44457&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44457&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44457&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44457&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44457&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44457&r=mysqlcfg