phpantom_lsp 0.7.0

Fast PHP language server with deep type intelligence. Generics, Laravel, PHPStan annotations. Ready in an instant.
Documentation
// test: null coalesce with nullable LHS resolves to union of both sides
// feature: completion
// Adapted from phpactor null-coalesce/null-coalesce_nullable.test
// When LHS is ?Foo, the ?? produces a union of Foo and the RHS type
// ignore: function return type not flowing through ?? in top-level context
// expect: fooMethod(
// expect: barMethod(
---
<?php

class Foo {
    public function fooMethod(): void {}
}

class Bar {
    public function barMethod(): void {}
}

function getOptional(): ?Foo { return null; }

$nullable = getOptional();
$bar = new Bar();

$baz = $nullable ?? $bar;
$baz-><>