phpantom_lsp 0.7.0

Fast PHP language server with deep type intelligence. Generics, Laravel, PHPStan annotations. Ready in an instant.
Documentation
// test: multiple if blocks with early return progressively narrow union type
// feature: completion
// Adapted from phpactor general/narrowing.test and if-statement/multiple_statements.test
// expect: birdMethod(
// expect_absent: dogMethod(
// expect_absent: catMethod(
---
<?php

class Dog {
    public function dogMethod(): void {}
}

class Cat {
    public function catMethod(): void {}
}

class Bird {
    public function birdMethod(): void {}
}

function test(Dog|Cat|Bird $animal): void {
    if ($animal instanceof Dog) {
        return;
    }

    if ($animal instanceof Cat) {
        return;
    }

    $animal-><>
}