|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-17 19:24 UTC] colder@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
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