php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30451 static properties don't work properly
Submitted: 2004-10-16 01:50 UTC Modified: 2005-05-18 17:32 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: guth at fiifo dot u-psud dot fr Assigned: andi (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-05-07 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: guth at fiifo dot u-psud dot fr
New email:
PHP Version: OS:

 

 [2004-10-16 01:50 UTC] guth at fiifo dot u-psud dot fr
Description:
------------
hello,

Yet another strange behaviour in PHP...

My english is always too bad to explain the problem, so have a look to the following code...

Reproduce code:
---------------
<?php

class A {

	protected static $property = TRUE;
	
	protected static function method() {
		return TRUE;
	}

}

class B extends A {

	public function __construct() {
		
		var_dump(self::method());
		var_dump(parent::method());
		
		var_dump(self::$property);
		var_dump(parent::$property);
	
	}
	
}

new B;
?>


Expected result:
----------------
bool(true)
bool(true)
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
bool(true)
Fatal error: Cannot access protected property A::$property in /www/test2.php on line 21

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-25 01:33 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-05-07 03:13 UTC] guth at fiifo dot u-psud dot fr
No change with the last CVS.
 [2005-05-09 11:32 UTC] sniper@php.net
Andi, (or Dmitry maybe?) can you look into this?
 [2005-05-18 17:32 UTC] stas@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Seems to work fine in PHP5 CVS. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 09 19:01:28 2025 UTC