- Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
- Cannot assign array to property Foo::$bar of type string string(3) "bar" array(0) { }
<?php
class Foo {
public string $bar;
public function __set($name, $value) {
var_dump($name, $value);
}
}
$foo = new Foo();
try {
$foo->bar = [];
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
unset($foo->bar);
$foo->bar = [];