mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +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.
27 lines
390 B
PHP
27 lines
390 B
PHP
--TEST--
|
|
Enum properties cannot be returned by-ref
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo: int {
|
|
case Bar = 0;
|
|
}
|
|
|
|
function &getBarValueByRef() {
|
|
$bar = Foo::Bar;
|
|
return $bar->value;
|
|
}
|
|
|
|
try {
|
|
$value = &getBarValueByRef();
|
|
$value = 1;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
var_dump(Foo::Bar->value);
|
|
|
|
?>
|
|
--EXPECT--
|
|
Cannot modify readonly property Foo::$value
|
|
int(0)
|