- var_dump: documentation ( source)
<?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());;