Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Bug #37667 (Object is not added into array returned by __get) --FILE-- <?php cla..

Decoded Output download

--TEST--
Bug #37667 (Object is not added into array returned by __get)
--FILE--
<?php

class Test
{
    protected $property = array('foo' => 'bar');

    function __get($name)
    {
        return $this->property;
    }
}

$obj = new Test;

var_dump($obj->property['foo']);
var_dump($obj->property[2]);

var_dump($obj);

$obj->property[] = 1;
$obj->property[] = 2;

var_dump($obj);

?>
--EXPECTF--
string(3) "bar"

Warning: Undefined array key 2 in %s on line %d
NULL
object(Test)#%d (1) {
  ["property":protected]=>
  array(1) {
    ["foo"]=>
    string(3) "bar"
  }
}

Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 20

Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21
object(Test)#%d (1) {
  ["property":protected]=>
  array(1) {
    ["foo"]=>
    string(3) "bar"
  }
}

Did this file decode correctly?

Original Code

--TEST--
Bug #37667 (Object is not added into array returned by __get)
--FILE--
<?php

class Test
{
    protected $property = array('foo' => 'bar');

    function __get($name)
    {
        return $this->property;
    }
}

$obj = new Test;

var_dump($obj->property['foo']);
var_dump($obj->property[2]);

var_dump($obj);

$obj->property[] = 1;
$obj->property[] = 2;

var_dump($obj);

?>
--EXPECTF--
string(3) "bar"

Warning: Undefined array key 2 in %s on line %d
NULL
object(Test)#%d (1) {
  ["property":protected]=>
  array(1) {
    ["foo"]=>
    string(3) "bar"
  }
}

Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 20

Notice: Indirect modification of overloaded property Test::$property has no effect in %sbug37667.php on line 21
object(Test)#%d (1) {
  ["property":protected]=>
  array(1) {
    ["foo"]=>
    string(3) "bar"
  }
}

Function Calls

None

Variables

None

Stats

MD5 7fa67cb3a3dfbe3f5ed59701f6845404
Eval Count 0
Decode Time 138 ms