Edit report at http://bugs.php.net/bug.php?id=54543&edit=1

 ID:                 54543
 Updated by:         [email protected]
 Reported by:        [email protected]
 Summary:            Late Static Binding on Properties and/or Inheritance
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Class/Object related
 Operating System:   Any
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Expected behavior. LSB applies to properties, but in PHP it was decided
to have static properties shared between classes and their subclasses
(via a reference set), possibly so that they can reliably be used in a
non-static contexts. This behavior can be changed by redeclaring the
property or manually breaking the reference set (possibly this ought to
be documented).


Previous Comments:
------------------------------------------------------------------------
[2011-04-15 22:46:25] [email protected]

Description:
------------
Should late static binding also apply to properties? My test here I
would have 

expected each result to be different, not the value of the last created
object. It 

is counter-intuitive to work on methods and not properties. I would
expect this 

behaviour with self:: but not static::



inb4 "we rejected this multiple times" i do not actually care about the
object 

class name like in my example, that was just an easy demo case.

Test script:
---------------
<?php



// [bob@cairne:test]$ php static.php 

// value: two two two



class old {

        static $prop = 'old';

        public function __construct() { static::$prop = get_class($this); }

}



class one extends old { }

class two extends old { }



$one = new one;

$two = new two;



printf("value: %s %s %s\n",old::$prop,one::$prop,two::$prop);



?>

Expected result:
----------------
value: old one two

Actual result:
--------------
value: two two two


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54543&edit=1

Reply via email to