#42681 [Asn->Bgs]: Static variables in sub/superclasses
| From: | helly@php.net | Date: | Thu, 06 Dec 2007 13:47:57 +0000 |
| Subject: | #42681 [Asn->Bgs]: Static variables in sub/superclasses | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-120420@lists.php.net to get a copy of this message | ||
ID: 42681
Updated by: helly@php.net
Reported By: alex94040 at yahoo dot com
-Status: Assigned
+Status: Bogus
Bug Type: Class/Object related
Operating System: *
PHP Version: 5.2.4
Assigned To: helly
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is different from 28442. In fact the static variables are
different here as 28442 proves. However you are only using one of them.
You need to wait for LSB to make it into PHP and use the new syntax
then. This will most likely be solved in 5.3.0.
Previous Comments:
------------------------------------------------------------------------
[2007-09-18 10:44:17] jani@php.net
Marcus, can you reply to this please?
------------------------------------------------------------------------
[2007-09-16 03:36:20] alex94040 at yahoo dot com
Description:
------------
This is a reactivation of bug 28442; that bug shows as "fixed/closed",
but the issue still repros.
We need to be able to redefine static members of classes (including
constants), and set them independently.
Reproduce code:
---------------
class ClassA
{
private static $cn;
public static function setName( $cn )
{
self::$cn = $cn;
}
public static function getName( )
{
return self::$cn;
}
}
class ClassB extends ClassA
{
private static $cn; // with or without this, result is the same
}
ClassA::setName( 'AAA' );
ClassB::setName( 'BBB' );
print( ClassA::getName() . "\n" ); // prints 'BBB'
print( ClassB::getName() . "\n" ); // prints 'BBB'
Expected result:
----------------
Result should read "AAA BBB"
Actual result:
--------------
Result actually reads "BBB BBB"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42681&edit=1