1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 15:38:49 +02:00
Files
archived-php-src/Zend/tests/enum/no-write-properties-through-references.phpt
T
Ilija Tovilo 269c8dac1d Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00

24 lines
344 B
PHP

--TEST--
Enum properties cannot be written to through references
--FILE--
<?php
enum Foo: int {
case Bar = 0;
}
try {
$bar = Foo::Bar;
$value = &$bar->value;
$value = 1;
} catch (Error $e) {
echo $e->getMessage() . "\n";
}
var_dump(Foo::Bar->value);
?>
--EXPECT--
Cannot acquire reference to property Foo::$value
int(0)