3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** @param array{foo: string} $strArr */ function bar(array $strArr): string { $strArr["foo"] .= "bar"; return $strArr["foo"]; } class Foo { /** @var array<string, string> */ private array $stuff = ["foo" => "foo"]; /** * @param non-empty-list<string> $param * @return string */ public function foo(array $param) { $arr = &$this->stuff[$param[0]]; // This seems to cause Psalm to blackout. bar($this->stuff); var_dump($this->stuff); /** @var string */ $x = $arr; /** @psalm-trace $x, $arr */; // This trace doesn't work, and $x's type appears to be mixed at this point. /** @psalm-trace $x */ return $x; } } $foo = new Foo(); $foo->foo(["foo"]);
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["foo"]=> &string(6) "foobar" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
136.99 ms | 405 KiB | 5 Q