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-- SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PRO..

Decoded Output download

--TEST--
SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
--FILE--
<?php

class C extends ArrayObject {
    public $p = 'object property';
}

$ao = new C(array('p'=>'array element'));
$ao->setFlags(ArrayObject::ARRAY_AS_PROPS);

echo "
--> Access the real property:
";
var_dump(isset($ao->p));
var_dump($ao->p);

echo "
--> Remove the real property and access the array element:
";
unset($ao->p);
var_dump(isset($ao->p));
var_dump($ao->p);

echo "
--> Remove the array element and try access again:
";
unset($ao->p);
var_dump(isset($ao->p));
var_dump($ao->p);

echo "
--> Re-add the real property:
";
$ao->p = 'object property';
var_dump(isset($ao->p));
var_dump($ao->p);
?>
--EXPECTF--
--> Access the real property:
bool(true)
string(15) "object property"

--> Remove the real property and access the array element:
bool(true)
string(13) "array element"

--> Remove the array element and try access again:
bool(false)

Warning: Undefined array key "p" in %s on line %d
NULL

--> Re-add the real property:
bool(true)
string(15) "object property"

Did this file decode correctly?

Original Code

--TEST--
SPL: Bug #45622 (isset($arrayObject->p) misbehaves with ArrayObject::ARRAY_AS_PROPS set
--FILE--
<?php

class C extends ArrayObject {
    public $p = 'object property';
}

$ao = new C(array('p'=>'array element'));
$ao->setFlags(ArrayObject::ARRAY_AS_PROPS);

echo "\n--> Access the real property:\n";
var_dump(isset($ao->p));
var_dump($ao->p);

echo "\n--> Remove the real property and access the array element:\n";
unset($ao->p);
var_dump(isset($ao->p));
var_dump($ao->p);

echo "\n--> Remove the array element and try access again:\n";
unset($ao->p);
var_dump(isset($ao->p));
var_dump($ao->p);

echo "\n--> Re-add the real property:\n";
$ao->p = 'object property';
var_dump(isset($ao->p));
var_dump($ao->p);
?>
--EXPECTF--
--> Access the real property:
bool(true)
string(15) "object property"

--> Remove the real property and access the array element:
bool(true)
string(13) "array element"

--> Remove the array element and try access again:
bool(false)

Warning: Undefined array key "p" in %s on line %d
NULL

--> Re-add the real property:
bool(true)
string(15) "object property"

Function Calls

None

Variables

None

Stats

MD5 648dc6d8cadff411e00772de0c522a97
Eval Count 0
Decode Time 90 ms