mirror of
https://github.com/php/php-src.git
synced 2026-04-19 14:01:01 +02:00
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
23 lines
348 B
PHP
23 lines
348 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 acquire reference to property Foo::$value
|
|
int(0)
|