Bug #53155 [Opn]: conditional class creation does not reset static variable in method

From: Date: Wed, 27 Oct 2010 00:54:21 +0000
Subject: Bug #53155 [Opn]: conditional class creation does not reset static variable in method
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155547@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53155&edit=1 ID: 53155 Updated by: felipe@php.net Reported by: frederic dot hardy at mageekbox dot net Summary: conditional class creation does not reset static variable in method Status: Open Type: Bug Package: Scripting Engine problem Operating System: FreeBSD PHP Version: 5.3.3 Block user comment: N New Comment: Probably related to bug #48623 Previous Comments: ------------------------------------------------------------------------ [2010-10-25 21:41:26] frederic dot hardy at mageekbox dot net 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) { } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53155&edit=1

« previous php.bugs (#155547) next »