Psalm
Get started
Documentation
Paid support
Plugins
Blog
GitHub
<?php /** * @psalm-assert-if-false string $value * @psalm-assert-if-true int $value */ function isRight(string|int $value): bool { return is_int($value); } function testRight(int $v): void {} function testLeft(string $v): void {} /** @var int|string */ $value = 0; isRight($value) ? testRight($value) : testLeft($value); if (isRight($value)) { testRight($value); } else { testLeft($value); } !isRight($value) ? testLeft($value) : testRight($value); if (isRight($value) !== true) { testLeft($value); } else { testRight($value); }
Snippet created on May 30 2023 at 21:34 UTC
Settings
Get link