I wanted to share my findings on static properties of anonymous classes.
So, given an anonymous class' object generating function like this:
<?php
function nc () {
return new class {
public static $prop = [];
};
}
?>
Getting a new object and changing the static property:
<?php
$a = nc();
$a::$prop[] = 'a';
var_dump($a::$prop);
?>
Now getting another object and changing the static property will change the original one, meaning that the static property is truly static:
<?php
$b = nc();
$b::$prop[] = 'b';
var_dump($b::$prop); assert($a::$prop === $b::$prop); ?>