github carthage-software/mago 1.0.0-rc.13

2 days ago

This release introduces an internal plugin system for the analyzer, adds new linter rules, and continues the focus on minimizing false positives.

New Features

Analyzer

  • Internal plugin system: Adds an extensible architecture for type providers, enabling custom return type inference for functions and methods
  • UnitEnum::cases() return type provider: Properly infers the return type of cases() on unit enums

Linter

  • New instanceof-stringable rule: Suggests using $x instanceof Stringable instead of the verbose is_object($x) && method_exists($x, '__toString') pattern

Bug Fixes

Analyzer

  • parent:: now works in traits with @require-extends annotation (#732)
  • Objects with __toString method can be cast to string without errors
  • Concrete-to-template type assertions no longer flagged as redundant
  • Explicit type assertions in ternary expressions are preserved correctly
  • Null access warnings suppressed on RHS of nullsafe operations (?->)
  • Redundant type comparisons are now properly reported
  • Template parameters with compatible constraints are allowed
  • Static enum types resolve correctly
  • String callables accepted; declared list parameter types in closures respected
  • Memoized values cleared after any invocation to prevent stale type information

Codex

  • $this handling corrected in type expansion
  • Static type resolves to concrete class when class name is known
  • Strings combiner fixed for accurate type unions
  • Array/list identical check corrected

Formatter

  • Arrow function ternary bodies wrapped in parentheses; outer calls break correctly
  • Argument lists break when an argument has a trailing line comment

Linter

  • Annotation spans narrowed to highlight minimal code regions

Type Syntax

  • Trailing comma allowed after open array additional fields

Full Changelog: 1.0.0-rc.12...1.0.0-rc.13

Don't miss a new mago release

NewReleases is sending notifications on new releases.