- Output for 8.4.1
- array(0) { }
- Output for 4.3.0
- Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/PSHJN on line 8
Process exited with code 255.
<?php
class Deferred {
//
}
class Test {
protected(set) array $loaded = [];
public Deferred $instance {
get => $this->instance ??= new Deferred();
set {
$this->instance = $value;
$this->loaded[$value::class] = $value;
}
}
}
$test = new Test();
$instance = $test->instance;
var_dump($test->loaded);