From:             levi at alliancesoftware dot com dot au
Operating system: Fedora Core 2
PHP version:      5.0.2
PHP Bug Type:     Zend Engine 2 problem
Bug description:  static member conflict with $this->member silently ignored

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 bug report at http://bugs.php.net/?id=30820&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30820&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=30820&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=30820&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30820&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30820&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30820&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30820&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30820&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30820&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30820&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=30820&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=30820&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30820&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30820&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30820&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30820&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30820&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30820&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30820&r=mysqlcfg

Reply via email to