On Mon, Sep 27, 2021 at 3:15 PM Sara Golemon <poll...@php.net> wrote:
> I think for consistency's sake, we'd want to provide a base constructor to > stdClass to take an associative array that maps into dynamic properties, > e.g. > > class stdClass { > public function __construct(array $props) { > foreach ($prop as $name => $val) { > $this->$name = $val; > } > } > } > > Then you could: > php> static $x3 = new stdClass(['key' => 'value']); > If the structure of `$something = {};` would ever be allowed in PHP, the following could be done instead: `$something = { ...$array };`. This will reduce the dependency on the stdClass.