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 #79683: Fake reflection scope affects __toString() --FILE-- <?php class A { ..
Decoded Output download
--TEST--
Bug #79683: Fake reflection scope affects __toString()
--FILE--
<?php
class A
{
private string $prop1 = '123';
public function __toString()
{
return $this->prop1;
}
}
class B
{
private string $prop2;
}
$b = new B();
$reflector = new ReflectionClass($b);
$property = $reflector->getProperty('prop2');
$property->setAccessible(true);
$property->setValue($b, new A());
var_dump($b);
?>
--EXPECT--
object(B)#1 (1) {
["prop2":"B":private]=>
string(3) "123"
}
Did this file decode correctly?
Original Code
--TEST--
Bug #79683: Fake reflection scope affects __toString()
--FILE--
<?php
class A
{
private string $prop1 = '123';
public function __toString()
{
return $this->prop1;
}
}
class B
{
private string $prop2;
}
$b = new B();
$reflector = new ReflectionClass($b);
$property = $reflector->getProperty('prop2');
$property->setAccessible(true);
$property->setValue($b, new A());
var_dump($b);
?>
--EXPECT--
object(B)#1 (1) {
["prop2":"B":private]=>
string(3) "123"
}
Function Calls
None |
Stats
MD5 | b743f0adab6d233aca0f7860aee81c91 |
Eval Count | 0 |
Decode Time | 114 ms |