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"]);

preferences:
35.17 ms | 404 KiB | 5 Q