ID:               44457
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ken at gizzar dot com
-Status:           Open
+Status:           Wont fix
 Bug Type:         Scripting Engine problem
 Operating System: Mac OS X
 PHP Version:      5.3CVS-2008-03-17 (snap)
 New Comment:

Late static bindings doesn't have anything to do with your case, late
static binding is simply a way of referencing things. The problem here
is the dynamic creation of static properties, which was rejected
multiple times.

If you want to store metadata in a static property, you can always use
an array with the classnames as indices:
self::$_metadata[get_called_class()] = ...


Previous Comments:
------------------------------------------------------------------------

[2008-03-17 17:06:49] ken at gizzar dot com

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 this bug report at http://bugs.php.net/?id=44457&edit=1

Reply via email to