php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35393 changing static protected members from outside the class
Submitted: 2005-11-25 14:46 UTC Modified: 2005-11-28 15:35 UTC
From: tony2001@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tony2001@php.net
New email:
PHP Version: OS:

 

 [2005-11-25 14:46 UTC] tony2001@php.net
Description:
------------
It's possible to change value of static protected member with a tricky code like the one below (pay attention to the "()" around the method call).

Reproduce code:
---------------
class ObjectPath
{
    static protected $type = array(0=>'main');

    static function getType()
    {
        return self::$type;
    }
}
var_dump(ObjectPath::getType());
$object_type = array_pop((ObjectPath::getType()));
var_dump(ObjectPath::getType());


Expected result:
----------------
array(1) {
  [0]=>
  string(4) "main"
}
array(1) {
  [0]=>
  string(4) "main"
}

Actual result:
--------------
array(1) {
  [0]=>
  string(4) "main"
}
array(0) {
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-25 14:49 UTC] tony2001@php.net
Assigned to Dmitry by his request.
 [2005-11-28 15:35 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC