Verified on latest main
PHPantom version / commit
phpantom_lsp 33718a6
Installation method
Built from source
Operating system
Linux x86_64
Editor
Zed
Bug description
@param array<non-empty-string, Tvalue|string|null> $data seems to be interpreted as @param Tvalue $data,
resulting in invalid detected return type: array<non-empty-string, array{bar: true, foo: ?string}|non-empty-string> instead of array<non-empty-string, bool|non-empty-string>.
Steps to reproduce
class Example {
/**
* @param array<non-empty-string,string|float|bool|null>
* @return array<non-empty-string,non-empty-string|float|bool>
*/
public function filter(array $value): array
{
return $this->filterOutNullAndEmptyStrings($value);
}
/**
* @template Tvalue of object|scalar
*
* @param array<non-empty-string, Tvalue|string|null> $data
*
* @return array<non-empty-string, Tvalue|non-empty-string>
*/
private function filterOutNullAndEmptyStrings(array $data): array
{
return array_filter($data, static fn (mixed $value): bool => null !== $value && '' !== $value);
}
}
Error output or panic trace
Return type array<non-empty-string, array{bar: true, foo: ?string}|non-empty-string> is incompatible with declared return type array<non-empty-string, non-empty-string|float|bool>
🪪 type_mismatch_return
.phpantom.toml
[diagnostics]
unresolved-member-access = true
extra-arguments = true
workspace = true
[indexing]
strategy = "full"
[phpstan]
command="tools/phpstan/vendor/bin/phpstan"
[phpcs]
command="tools/phpcs/vendor/bin/phpcs"
[formatting]
php-cs-fixer="tools/php-cs-fixer/vendor/bin/php-cs-fixer"
phpcbf="tools/phpcs/vendor/bin/phpcbf"
Additional context
This is a complex use case, but psalm, mago, and phpstan accept it without raising issues.
Verified on latest main
mainbranch.PHPantom version / commit
phpantom_lsp 33718a6
Installation method
Built from source
Operating system
Linux x86_64
Editor
Zed
Bug description
@param array<non-empty-string, Tvalue|string|null> $dataseems to be interpreted as@param Tvalue $data,resulting in invalid detected return type:
array<non-empty-string, array{bar: true, foo: ?string}|non-empty-string>instead ofarray<non-empty-string, bool|non-empty-string>.Steps to reproduce
Error output or panic trace
.phpantom.toml
Additional context
This is a complex use case, but
psalm,mago, andphpstanaccept it without raising issues.