Skip to content

7.21.1

Latest

Choose a tag to compare

@github-actions github-actions released this 26 Nov 00:44
9c65a30

Fixes

Taint analysis

  • No crash ("Undefined array key -1") when an array whose values a foreach wrote back under their keys reaches a cast. (#14965, @orklah)
  • An unpacked element taints only the parameter it fills: in f(...[safe(), $_GET['x']]), $first is no longer tainted. (#14979, @shu-chen-dot-ca)
  • What array_walk() and array_walk_recursive() callbacks write to their by-reference param flows into the array. (#14963, @danog)

Templates and type variables

  • class-string<T>, key-of<T>, value-of<T>, T[K] and properties-of<T> resolve when new binds the template: (new ReflectionClass(new stdClass()))->getName() is class-string<stdClass>. An inherited self<T&C> assertion narrows a subclass again. (#14981, @orklah)
  • No infinite recursion when an object is added to its own template, and properties-of<T> over several classes includes the properties of each. (#14982, @orklah)
  • A class-string<T>|T param given a class string binds T to the class only, without a false IncompatibleTypeParameters. (#14994, @orklah)
  • No hang when a class with @template T of static calls a method returning T on $this or static::. (#14978, @shu-chen-dot-ca)

Narrowing, loops and arrays

  • $x != "" and $x != 0 remove null and the loosely equal bool from $x. (#14995, @orklah)
  • A variable that a nested foreach over a non-empty list assigns before every break is defined after it. (#12439, @jarstelfox)
  • A variable read where it is undefined is no longer possibly undefined on the loop's next iteration, and with extract() a variable assigned on one path is no longer read as possibly undefined. (#12442, @jarstelfox)
  • No false PossiblyUndefinedVariable on $r?->m() ?? [], or TypeDoesNotContainNull on $r?->p ?? [], when $r may be undefined. (#14998, @orklah)
  • A list written under keys it already has (its own foreach key, array_key_last()) keeps its shape. (#15009, @orklah)
  • $a + [...] combined with a shape: no false PossiblyUndefinedArrayOffset on keys both declare, and no InvalidArgument when it is passed to a sealed shape param. (#15002, @orklah)
  • Offsets of DOMNamedNodeMap, Dom\NamedNodeMap, Dom\NodeList and Dom\HTMLCollection are read by position or name instead of reporting InvalidArrayAccess. (#14535, @jirkace)

Properties and constructors

  • $object::$prop is checked as a static fetch on the object's class, so undeclared and instance-only properties report UndefinedPropertyFetch. (#12046, @HenkPoley)
  • No false MissingConstructor for a subclass inheriting the real constructor of a class a stub declares without one, and no PropertyNotSetInConstructor after Ancestor::__construct(). (#15001, @orklah)
  • @psalm-suppress UndefinedConstant applies to constants in docblock types (@var int-mask<NO_SUCH_CONSTANT>). (#13540, @alies-dev)

Purity

  • The DateTime and DateTimeImmutable constructors require only the time capability, and the DateInterval constructor is pure. (#14962, @jirkace)

Stubs

  • Global constants added in PHP 8.5 (CURLFOLLOW_ALL, ETH_P_ALL, PHP_BUILD_DATE, …) are declared. (#13019, @alies-dev)
  • DateInterval::createFromDateString() no longer returns false on PHP 8.3+. (#11849, @xelaris)
  • SQLite3Result::columnName() can return false. (#11819, @stof)
  • ReflectionObject is generic, like ReflectionClass. (#11774, @Kenny1911)
  • The property map covers ext-mongodb 2.3. (#11838, @alcaeus)

Language server and --alter

  • The language server keeps the types and references of a file without class methods when it analyses another file, so hover and go-to-definition keep working there. (#15003, @danog)
  • --alter writes only native types the analysed PHP version supports (no object below 7.2) and writes int|string for array-key from PHP 8.0. (#14933, @orklah)

Internal changes

New Contributors

Full Changelog: 7.21.0...7.21.1