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 enum Foo: int { ..

Decoded Output download

--TEST--
Test ReflectionProperty::setValue() error cases.
--FILE--
<?php

enum Foo: int {
    case Bar = 0;
}

$reflection = new ReflectionProperty(Foo::class, 'value');

try {
    $reflection->setValue(Foo::Bar, 1);
} catch (Error $e) {
    echo $e->getMessage() . "
";
}

var_dump(Foo::Bar->value);

?>
--EXPECT--
Cannot modify readonly property Foo::$value
int(0)

Did this file decode correctly?

Original Code

--TEST--
Test ReflectionProperty::setValue() error cases.
--FILE--
<?php

enum Foo: int {
    case Bar = 0;
}

$reflection = new ReflectionProperty(Foo::class, 'value');

try {
    $reflection->setValue(Foo::Bar, 1);
} catch (Error $e) {
    echo $e->getMessage() . "\n";
}

var_dump(Foo::Bar->value);

?>
--EXPECT--
Cannot modify readonly property Foo::$value
int(0)

Function Calls

None

Variables

None

Stats

MD5 f1acc0e3ffe33b886fb9119730adee1f
Eval Count 0
Decode Time 104 ms