mirror of
https://github.com/php/php-src.git
synced 2026-04-17 13:01:02 +02:00
RFC: https://wiki.php.net/rfc/enumerations Co-authored-by: Nikita Popov <nikita.ppv@gmail.com> Closes GH-6489.
38 lines
537 B
PHP
38 lines
537 B
PHP
--TEST--
|
|
Enum properties cannot be written to
|
|
--FILE--
|
|
<?php
|
|
|
|
enum Foo {
|
|
case Bar;
|
|
}
|
|
|
|
enum IntFoo: int {
|
|
case Bar = 0;
|
|
}
|
|
|
|
$bar = Foo::Bar;
|
|
try {
|
|
$bar->name = 'Baz';
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
$intBar = Foo::Bar;
|
|
try {
|
|
$intBar->name = 'Baz';
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
try {
|
|
$intBar->value = 1;
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
Enum properties are immutable
|
|
Enum properties are immutable
|
|
Enum properties are immutable
|