PHPantom version
phpantom_lsp 0.8.0-dirty
Installation method
Pre-built binary from GitHub Releases
Operating system
Windows x86_64
Editor
VS Code
Bug description
PHPantom reports a type mismatch in an elseif condition after the previous if branch assigns a different type to the same variable.
Expected: no diagnostic. The elseif condition only runs when the first branch did not run, so the assignment inside the first branch should not affect the argument type in the elseif condition.
Actual: PHPantom reports Argument 1 ($string) expects string, got bool.
Steps to reproduce
- Use any supported PHP version.
- Create a PHP file with:
<?php
function normalizeBooleanString(string $value): bool
{
if (mb_strtolower($value) === 't') {
$value = true;
} elseif (mb_strtolower($value) === 'f') {
$value = false;
}
return (bool) $value;
}
- Run diagnostics.
PHPantom reports:
7 Argument 1 ($string) expects string, got bool
type_mismatch_argument
Error output or panic trace
.phpantom.toml
Additional context
This looks like path-insensitive propagation from the first if branch into the elseif condition. The assignment $value = true can affect code after the whole if / elseif, but it cannot affect the condition of the elseif branch itself.
Binary source
Originally observed in the VS Code extension v0.5.0. Reproduced with the extension-cached GitHub Releases binary
PHPantom version
phpantom_lsp 0.8.0-dirty
Installation method
Pre-built binary from GitHub Releases
Operating system
Windows x86_64
Editor
VS Code
Bug description
PHPantom reports a type mismatch in an
elseifcondition after the previousifbranch assigns a different type to the same variable.Expected: no diagnostic. The
elseifcondition only runs when the first branch did not run, so the assignment inside the first branch should not affect the argument type in theelseifcondition.Actual: PHPantom reports
Argument 1 ($string) expects string, got bool.Steps to reproduce
PHPantom reports:
Error output or panic trace
.phpantom.toml
Additional context
This looks like path-insensitive propagation from the first
ifbranch into theelseifcondition. The assignment$value = truecan affect code after the wholeif/elseif, but it cannot affect the condition of theelseifbranch itself.Binary source
Originally observed in the VS Code extension v0.5.0. Reproduced with the extension-cached GitHub Releases binary