Verified on latest main
PHPantom version / commit
phpantom_lsp 0.9.0
Installation method
Pre-built binary from GitHub Releases
Operating system
macOS x86_64 (Intel)
Editor
Neovim
Bug description
instanceof narrowing is not applied to repeated method calls
PHPantom reports an error for the following code:
if ($this->getHttpKernel() instanceof TerminableInterface) {
$this->getHttpKernel()->terminate($request, $response);
}
Diagnostic:
Method 'terminate' not found on class 'Symfony\Component\HttpKernel\HttpKernelInterface'
I would expect no diagnostic here because the instanceof TerminableInterface check should narrow the type inside the if block, and TerminableInterface defines the terminate() method.
Steps to reproduce
vendor/symfony/http-kernel/Kernel.php
if ($this->getHttpKernel() instanceof TerminableInterface) {
$this->getHttpKernel()->terminate($request, $response); * Method 'terminate' not found on class 'Symfony\Component\HttpKernel\HttpKernelInterface'
}
Error output or panic trace
.phpantom.toml
Additional context
No response
Verified on latest main
mainbranch.PHPantom version / commit
phpantom_lsp 0.9.0
Installation method
Pre-built binary from GitHub Releases
Operating system
macOS x86_64 (Intel)
Editor
Neovim
Bug description
instanceof narrowing is not applied to repeated method calls
PHPantom reports an error for the following code:
if ($this->getHttpKernel() instanceof TerminableInterface) {
$this->getHttpKernel()->terminate($request, $response);
}
Diagnostic:
Method 'terminate' not found on class 'Symfony\Component\HttpKernel\HttpKernelInterface'
I would expect no diagnostic here because the instanceof TerminableInterface check should narrow the type inside the if block, and TerminableInterface defines the terminate() method.
Steps to reproduce
vendor/symfony/http-kernel/Kernel.php
if ($this->getHttpKernel() instanceof TerminableInterface) {
$this->getHttpKernel()->terminate($request, $response); * Method 'terminate' not found on class 'Symfony\Component\HttpKernel\HttpKernelInterface'
}
Error output or panic trace
.phpantom.toml
Additional context
No response