3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { /** @var int */ public static $bar = 0; public ?string $test = null; /** @psalm-external-mutation-free */ public function setTest(string $value) : void { $this->test = $value; ++self::$bar; } } class Bar { /** @psalm-mutation-free */ function test() : void { $foo = new Foo(); $foo->setTest('abcd'); } } $bar = new Bar(); $a = Foo::$bar; /** @psalm-suppress UnusedMethodCall irrelevant */ $bar->test(); $b = Foo::$bar; assert($a === $b);

preferences:
29.99 ms | 404 KiB | 5 Q