#35393 [Opn->Asn]: changing static protected members from outside the class

From: Date: Fri, 25 Nov 2005 13:49:05 +0000
Subject: #35393 [Opn->Asn]: changing static protected members from outside the class
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-88966@lists.php.net to get a copy of this message
 ID:               35393
 Updated by:       tony2001@php.net
 Reported By:      tony2001@php.net
-Status:           Open
+Status:           Assigned
 Bug Type:         Scripting Engine problem
 Operating System: Linux
 PHP Version:      5.1.0
-Assigned To:      
+Assigned To:      dmitry
 New Comment:

Assigned to Dmitry by his request.


Previous Comments:
------------------------------------------------------------------------

[2005-11-25 14:46:39] 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) {
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35393&edit=1


Thread (3 messages)

« previous php.bugs (#88966) next »