- Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- int(0) int(1)
<?php
class Foo {
private function &getState(): array {
static $state = ['counter' => 0];
return $state;
}
public function count(): int {
return $this->getState()['counter']++;
}
}
$x = new Foo();
$y = new Foo();
var_dump($x->count(), $y->count());;