php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30837 Arrow operator with static properties does not show and strict error
Submitted: 2004-11-19 14:56 UTC Modified: 2004-11-19 16:36 UTC
From: jordi at jcanals dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.2 OS: Windows XP Pro
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jordi at jcanals dot net
New email:
PHP Version: OS:

 

 [2004-11-19 14:56 UTC] jordi at jcanals dot net
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-19 16:36 UTC] tony2001@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Duplicate of #30820.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 18 18:00:02 2025 UTC