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
 [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

Pull Requests

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 Nov 21 10:01:29 2024 UTC