summaryrefslogtreecommitdiff
path: root/Zend/tests/enum/no-write-properties-through-foreach-reference.phpt
blob: d1c211802fa28081dd4dbebade2a50b4edba50de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)