|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44315 Late static binding not working for variables
Submitted: 2008-03-03 01:18 UTC Modified: 2008-03-03 01:46 UTC
From: m dot kurzyna at crystalpoint dot pl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3CVS-2008-03-03 (snap) OS: PLD Linux
Private report: No CVE-ID: None
 [2008-03-03 01:18 UTC] m dot kurzyna at crystalpoint dot pl
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:
	class B {
		static protected $counter = 0;
		public function __construct() {

	class C extends B {
		public function __construct() {

	new B;
	new C;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-03 01:31 UTC] m dot kurzyna at crystalpoint dot pl
The snapshot used was php-5.3-2008-03-02-21:30.
 [2008-03-03 01:38 UTC]
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 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:46 UTC] m dot kurzyna at crystalpoint dot pl
Hm.. ok. My bad. Thanks for the extra info.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 02:01:30 2024 UTC