|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-27 02:54 UTC] felipe@php.net
[2012-05-11 21:05 UTC] ash at itsash dot co dot uk
[2012-10-26 16:14 UTC] dagguh at gmail dot com
[2015-01-08 20:35 UTC] danack@php.net
-Status: Open
+Status: Not a bug
[2015-01-08 20:35 UTC] danack@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 09:00:01 2025 UTC |
Description: ------------ when a class which extends a parent class with a method which define a static variable is created then a condition is verified, the static variable is not reset in the chield class. Test script: --------------- <?php abstract class singleton { public static function getInstance() { static $instance = null; if ($instance === null) { $instance = new static(); } return $instance; } protected function __construct() {} protected function __clone() {} } class a extends singleton { } var_dump(a::getInstance()); if (1 > 0) { class b extends a {} } var_dump(b::getInstance()); ?> Expected result: ---------------- object(a)#1 (0) { } object(b)#2 (0) { } Actual result: -------------- object(a)#1 (0) { } object(a)#1 (0) { }