mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00

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.
20 lines
246 B
PHP
20 lines
246 B
PHP
--TEST--
|
|
Enum case disallows dynamic properties
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo {
|
|
case Bar;
|
|
}
|
|
|
|
$bar = Foo::Bar;
|
|
|
|
try {
|
|
$bar->baz = 'Baz';
|
|
} catch (\Error $e) {
|
|
echo $e->getMessage();
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Cannot create dynamic property Foo::$baz
|