#44315 [Bgs]: Late static binding not working for variables
| From: | m dot kurzyna at crystalpoint dot pl | Date: | Mon, 03 Mar 2008 01:46:18 +0000 |
| Subject: | #44315 [Bgs]: Late static binding not working for variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-122849@lists.php.net to get a copy of this message | ||
ID: 44315
User updated by: m dot kurzyna at crystalpoint dot pl
Reported By: m dot kurzyna at crystalpoint dot pl
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: PLD Linux
PHP Version: 5.3CVS-2008-03-03 (snap)
New Comment:
Hm.. ok. My bad. Thanks for the extra info.
Previous Comments:
------------------------------------------------------------------------
[2008-03-03 01:38:51] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
in C::__construct, static resolves to C, and C::$counter is not defined
per-se, a fallback occurs and B::$counter is incremented. Nothing to do
with late static bindings.
------------------------------------------------------------------------
[2008-03-03 01:31:17] m dot kurzyna at crystalpoint dot pl
The snapshot used was php-5.3-2008-03-02-21:30.
------------------------------------------------------------------------
[2008-03-03 01:18:47] m dot kurzyna at crystalpoint dot pl
Description:
------------
Late static binding doesn't seem to apply to static class variables.
Example is rather self explanatory (construtor using static keyword
should increment variable in calling class).
Reproduce code:
---------------
<?php
class B {
static protected $counter = 0;
public function __construct() {
++static::$counter;
var_dump(static::$counter);
}
}
class C extends B {
public function __construct() {
++static::$counter;
var_dump(static::$counter);
}
}
new B;
new C;
?>
Expected result:
----------------
int(1)
int(1)
Actual result:
--------------
int(1)
int(2)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44315&edit=1