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
Status: Closed Package: Scripting Engine problem
PHP Version: 5.1.0 OS: Linux
Private report: No CVE-ID:
 [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-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 16:02:23 2014 UTC