From:             jordi at jcanals dot net
Operating system: Windows XP Pro
PHP version:      5.0.2
PHP Bug Type:     Zend Engine 2 problem
Bug description:  Arrow operator with static properties does not show and 
strict error

Description:
------------
If you assign a static property by using the $this->varname operator, then
the engine creates a new class property called $this->varname instead of
reporting an E_STRICT warning.

This can insert some bugs to the code, as the property is defined as
public static, and no errors nor warnings are reported when referencing
the variable using the arrow operator.

I think that if error_reporting is set to E_ALL | E_STRICT, an strict
error should be received.

To test this, I have in my PHP.INI the following parameters:

error_reporting = E_ALL | E_STRICT
display_errors = On
zend.ze1_compatibility_mode = Off


Reproduce code:
---------------
<?php
error_reporting(E_ALL | E_STRICT);

class staticMethods
{
        
        public static $myvar;
        
        public function __construct()
        {
                $this->myvar = 'Test';
                self::$myvar = 'Whats Up?';
        }
        
        public function showMyVar()
        {
                echo '<br>Here myvar: ', self::$myvar;
                echo '<br>Other myvar: ', $this->myvar;
        }
}

$myclass = new staticMethods();
$myclass->showMyVar();

?>


Expected result:
----------------
You can see that error_reporting is set to E_ALL | E_STRICT, and no errors
nor warnings are reported.

I think it shoud report an E_STRICT warning when the myvar property is
assigned by $this->myvar (in the sample's constructor)

What it's done is created a new myvar property and assigned the value to
it.

Actual result:
--------------
Running this script the output is:

Here myvar: Whats Up?
Other myvar: Test

And no warnings, errors or notices are reported.

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

Reply via email to