PHPantom version
phpantom_lsp 0.8.0-2-g7c86d78c
Installation method
Pre-built binary from GitHub Releases
Operating system
Linux x86_64
Editor
Zed
Bug description
Wrong type detection
Argument 2 ($string) expects string, got array<string>
For this line:
$rule = explode(':', $rule);
This is wrong. The $rule passed to explode() should use the type from before the assignment. The return type of explode() should only apply to $rule after the RHS has been checked.
Expected:
$rule in the explode call should be mixed and the LHS $rule should be array<string>
$rule = explode(':', $rule)
Actual:
$rule = explode(':', $rule) // LSP treats both $rule as the same type (array<string>)
Steps to reproduce
<?php
class Validator {
private array $rules;
/**
* @return array
*/
public function getRules() {
return $this->rules;
}
}
function x(Validator $validator) {
foreach ($validator->getRules() as $field => $rules)
{
foreach ($rules as $rule)
{
$rule = explode(':', $rule);
}
}
}
Error output or panic trace
.phpantom.toml
Additional context
No response
PHPantom version
phpantom_lsp 0.8.0-2-g7c86d78c
Installation method
Pre-built binary from GitHub Releases
Operating system
Linux x86_64
Editor
Zed
Bug description
Wrong type detection
For this line:
This is wrong. The
$rulepassed toexplode()should use the type from before the assignment. The return type ofexplode()should only apply to$ruleafter the RHS has been checked.Expected:
$rulein the explode call should bemixedand the LHS$ruleshould bearray<string>Actual:
Steps to reproduce
Error output or panic trace
.phpantom.toml
defaultAdditional context
No response