#30820 [Asn->Csd]: static member conflict with $this->member silently ignored

From: Date: Wed, 08 Jun 2005 08:08:56 +0000
Subject: #30820 [Asn->Csd]: static member conflict with $this->member silently ignored
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-80032@lists.php.net to get a copy of this message
ID: 30820 Updated by: dmitry@php.net Reported By: levi at alliancesoftware dot com dot au -Status: Assigned +Status: Closed Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS-2005-03-06 Assigned To: andi New Comment: Fixed in CVS HEAD and PHP_5_0. Previous Comments: ------------------------------------------------------------------------ [2004-11-18 02:40:09] levi at alliancesoftware dot com dot au Description: ------------ If you declare a static data member (eg x), $this->x refers to a different variable without generating any warnings. Arguably, the proper behavior when setting a class variable through $this should first be to check if there are any static member variables of the same name and *then* check for instantiated member variables. Reproduce code: --------------- #!/usr/local/bin/php5 -q <? // error reporting is set to E_ALL in php.ini class Blah { public static $x; public function show() { Blah::$x = 1; $this->x = 5; // no warning, but refers to different variable echo ' Blah::$x = '. Blah::$x ."\n"; echo '$ this->x = '. $this->x ."\n"; } } $b = new Blah(); $b->show(); ?> Expected result: ---------------- either: (preferable) Blah::$x = 5 $this->x = 5 -or- at the minimum, display a warning Actual result: -------------- Blah::$x = 1 $this->x = 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30820&edit=1

« previous php.bugs (#80032) next »