diff options
Diffstat (limited to 'Zend/tests/enum/no-write-properties.phpt')
-rw-r--r-- | Zend/tests/enum/no-write-properties.phpt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Zend/tests/enum/no-write-properties.phpt b/Zend/tests/enum/no-write-properties.phpt new file mode 100644 index 0000000000..13cbe69e74 --- /dev/null +++ b/Zend/tests/enum/no-write-properties.phpt @@ -0,0 +1,37 @@ +--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 |