mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00

$obj->ro[] = 42;, passByRef($obj->ro); and the likes should emit an indirect modification error message. This message already existed but was used inconsistently.
22 lines
354 B
PHP
22 lines
354 B
PHP
--TEST--
|
|
Enum properties cannot be written to through reference in foreach
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo: int {
|
|
case Bar = 0;
|
|
}
|
|
|
|
try {
|
|
$bar = Foo::Bar;
|
|
foreach ([1] as &$bar->value) {}
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
var_dump(Foo::Bar->value);
|
|
|
|
?>
|
|
--EXPECT--
|
|
Cannot indirectly modify readonly property Foo::$value
|
|
int(0)
|