1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/reflection/tests/ReflectionProperty_setValue_readonly.phpt
Nikita Popov caefc6a507 Don't use custom object handlers for enum properties
Instead mark name/value as readonly and the class as
NO_DYNAMIC_PROPERTIES. This gives us the desired limitations
using native features.

In fact, this also fixes a bug where opcache cache slot merging
might result in a write to the name/value properties being
allowed. The readonly implementation handles this case correctly.
2021-08-13 16:44:39 +02:00

24 lines
368 B
PHP

--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)