github carthage-software/mago 1.0.0-beta.18
Mago 1.0.0-beta.18

11 hours ago

Mago 1.0.0-beta.18

This release introduces a major step forward in the analyzer's accuracy and its understanding of advanced PHPDoc, headlined by full support for property assertions. We've also landed a series of critical correctness fixes for match expressions and array shape analysis, eliminating a significant number of false positives.

✨ New Feature: Property Assertions

The analyzer now has full support for property-level assertions like @psalm-assert, @phpstan-assert, @assert, and their variants. This allows the analyzer to correctly understand and apply type narrowing from assertion helper methods that operate on object properties.

/**
 * @var null|array{'uuid': string}
 */
private null|array $data;

/**
 * @assert !null $this->data
 */
private function assertDataIsNotNull(): void
{
    // ...
}

public function getUuid(): string
{
    // Mago now understands that after this call, $this->data is not null.
    $this->assertDataIsNotNull();

    return $this->data['uuid']; // No error!
}

This change is a huge improvement for analyzing object-oriented code that relies on assertion helpers to maintain type safety.

🚀 Major Analyzer Correctness Improvements

  • match (true) Exhaustiveness (#459): A major bug has been fixed where the analyzer would incorrectly report match-not-exhaustive errors for valid match (true) expressions. The analyzer now correctly understands this common pattern for type narrowing and control flow.

  • Array Shape Reconciliation (#459): The core type system is now much smarter at combining and subtracting specific, "sealed" array shapes (e.g., list{true, false}). This makes type inference in conditional logic far more accurate, especially for match expressions on array subjects, e.g match ([$is_foo, $is_bar]).

  • Array Shape Key Parsing (#466): Fixed a critical bug where unquoted string keyword keys in PHPDoc array shapes (e.g., {self: string}) could be incorrectly resolved as class names, which was a significant source of false positives.

📄 Documentation

  • Fixed incorrect table formatting in the command reference documentation. (Thanks, @sasezaki!)

Closed Issues


Full Changelog: 1.0.0-beta.17...1.0.0-beta.18

Don't miss a new mago release

NewReleases is sending notifications on new releases.