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 keeps an old array|false type after a variable is reassigned from one of its own array offsets.
Expected: after $value = $value[0], later uses of $value should not still be treated as the previous array|false result.
Actual: PHPantom reports type_mismatch_argument when $value is passed to string parameters.
Steps to reproduce
- Use any supported PHP version.
- Create a PHP file with:
<?php
function stripFlat(string $value): string
{
$value = preg_split('/(, flat \d+.*)/u', $value, 0, PREG_SPLIT_DELIM_CAPTURE);
$value = $value[0];
$value = preg_split('/(, room \d+.*)/u', $value, 0, PREG_SPLIT_DELIM_CAPTURE);
$value = $value[0];
return trim($value);
}
- Run diagnostics.
PHPantom reports:
8 Argument 2 ($subject) expects string, got array|false
11 Argument 1 ($string) expects string, got array|false
Error output or panic trace
.phpantom.toml
Additional context
Using a separate $parts variable avoids this false positive:
$parts = preg_split('/.../', $value, 0, PREG_SPLIT_DELIM_CAPTURE);
$value = $parts[0];
The issue appears when the same variable is reused for both the array result and the extracted string.
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 keeps an old
array|falsetype after a variable is reassigned from one of its own array offsets.Expected: after
$value = $value[0], later uses of$valueshould not still be treated as the previousarray|falseresult.Actual: PHPantom reports
type_mismatch_argumentwhen$valueis passed to string parameters.Steps to reproduce
PHPantom reports:
Error output or panic trace
.phpantom.toml
Additional context
Using a separate
$partsvariable avoids this false positive:The issue appears when the same variable is reused for both the array result and the extracted string.
Binary source
Originally observed in the VS Code extension v0.5.0. Reproduced with the extension-cached GitHub Releases binary