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-- Test ReflectionProperty::setValue() error cases. --FILE-- <?php class TestClass ..
Decoded Output download
--TEST--
Test ReflectionProperty::setValue() error cases.
--FILE--
<?php
class TestClass {
public $pub;
public $pub2 = 5;
static public $stat = "static property";
protected $prot = 4;
private $priv = "keepOut";
}
class AnotherClass {
}
$instance = new TestClass();
$instanceWithNoProperties = new AnotherClass();
$propInfo = new ReflectionProperty('TestClass', 'pub2');
echo "
Protected property:
";
$propInfo = new ReflectionProperty('TestClass', 'prot');
$propInfo->setValue($instance, "NewValue");
var_dump($propInfo->getValue($instance));
echo "
Instance without property:
";
$propInfo = new ReflectionProperty('TestClass', 'pub2');
var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue"));
var_dump($instanceWithNoProperties->pub2);
?>
--EXPECT--
Protected property:
string(8) "NewValue"
Instance without property:
NULL
string(8) "NewValue"
Did this file decode correctly?
Original Code
--TEST--
Test ReflectionProperty::setValue() error cases.
--FILE--
<?php
class TestClass {
public $pub;
public $pub2 = 5;
static public $stat = "static property";
protected $prot = 4;
private $priv = "keepOut";
}
class AnotherClass {
}
$instance = new TestClass();
$instanceWithNoProperties = new AnotherClass();
$propInfo = new ReflectionProperty('TestClass', 'pub2');
echo "\nProtected property:\n";
$propInfo = new ReflectionProperty('TestClass', 'prot');
$propInfo->setValue($instance, "NewValue");
var_dump($propInfo->getValue($instance));
echo "\n\nInstance without property:\n";
$propInfo = new ReflectionProperty('TestClass', 'pub2');
var_dump($propInfo->setValue($instanceWithNoProperties, "NewValue"));
var_dump($instanceWithNoProperties->pub2);
?>
--EXPECT--
Protected property:
string(8) "NewValue"
Instance without property:
NULL
string(8) "NewValue"
Function Calls
None |
Stats
MD5 | d1ddde3fe9db7d5706095f19b90367fa |
Eval Count | 0 |
Decode Time | 63 ms |