github carthage-software/mago 1.64.0
Mago 1.64.0

3 hours ago

Mago 1.64.0 lets a class declare what a yield of its instances returns, and fixes 21 bugs, most of them in the analyzer and the PHP stubs.

✨ Features

Analyzer

  • Typed yields: @mago-yield T on a class makes yield $load return T, such as User for a Load<User>. (#2944, cbd34e0)

A class inherits the tag from its parents and interfaces. When any part of the yielded value lacks the tag, yield keeps the generator's send type.

🐛 Bug Fixes

Analyzer

Arrays

  • isset() and if: keeps an array key that isset() proved to exist after an if that does not change it. (#2953, fd82833)
  • Class constant keys: treats $row[self::KEY] and $row['key'] as the same key when the constant holds 'key'. (fd5cf55)
  • empty() on array keys: no longer adds null to an array key that holds a non-null value after an empty() check on it. (d3a653d)
  • String-key writes: $data['a'][$key] = 1 with a string $key makes $data['a'] a keyed array, not a list. (016e74e)
  • Missing shape keys: isset() on a key a closed array shape lacks no longer types the key like the shape's other values. (2b0a5d8)

Narrowing

  • === []: narrows a value compared with [] to the empty array, not to Countable. (#2880, #2936, f3039d3)
  • Assignments in branches: drops what an outer condition said about a variable that an if branch assigns. (#2881, #2939, 7f8d79d)
  • $this in traits: narrows $this in a trait after an instanceof check, such as assert($this instanceof Base). (#2935, 6bea50f)
  • Nested property reads: reports a possibly null object in $a->b->c read again after an isset() or empty() check. (#2940, eabab17)

Classes and Closures

  • Dynamic properties: stops reporting non-existent-property for classes marked #[AllowDynamicProperties]. (#2911, 2b4c6e4)
  • Unknown parent classes: allows calls and property reads on A&B when B extends a class Mago cannot find. (4d82dae)
  • Typed closure parameters: a closure parameter typed Box gets Box<Product> from the expected callable. (#2952, 34042ec)

Codex

  • Inherited assertions: resolves templates in identity (=T) and equality assertions a class inherits from a generic parent. (95d0d6e)

Prelude

  • Constant values: gives eleven constants, six of them on Pdo\Sqlite, the values PHP uses. (#2926, #2927, 183b9a3)
  • RegexIterator: adds seven missing methods, such as getMode() and setFlags(). (#2928, #2929, da94240)
  • Nonexistent symbols: removes 35 symbols that no PHP version defines, such as S_ALL and PDO::__sleep(). (#2930, #2931, c0d5980)
  • __debugInfo(): adds the method to ArrayObject, ArrayIterator, SimpleXMLElement and Generator. (#2950, #2951, 751fab9)
  • PHP 8.6 curl constants: adds five constants, such as CURLOPT_SEEKFUNCTION. (#2946, #2947, 0f12b1e)
  • PHP versions: corrects the versions of four symbols, such as SensitiveParameter and opcache_jit_blacklist(). (#2948, #2949, 1a1ca9d)

Semantics

  • final property hooks: reports a final property hook that is also abstract or private. (#2932, #2933, 78f35b7)
  • Virtual properties: reports a virtual property with private(set) or protected(set) and only one hook. (#2942, #2943, 779c120)

🧩 Extension Protocol

No protocol changes in this release.

🙏 Thank You

Contributors

Thank you to everyone who contributed to this release:

Issue Reporters

Thank you to everyone who reported issues that shaped this release:

Full Changelog: 1.63.2...1.64.0

Don't miss a new mago release

NewReleases is sending notifications on new releases.