Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php function getFoo(): ?int { return rand(0, 1) === 1 ? 1 : null; } function test(?stdClass $existing = null): void { $foo = getFoo(); $bar = getFoo(); /** @psalm-trace $existing */; if ($foo !== null) { assert($foo === 1); } elseif ($existing === null) { throw new \RuntimeException('foo'); } /** @psalm-trace $existing */; if ($bar !== null) { assert($bar === 1); } elseif ($existing === null) { throw new \RuntimeException('bar'); } } test(null);
Snippet created on June 11 2023 at 18:08 UTC
Settings
Get link