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