You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SourceText, the stored form of a SourceFile's text, plain (SourceText::new) or LZ4-compressed (SourceText::compressed), with AnalysisSession::upsert_source_text and AnalysisSession::warm_start_sources for hosts that build it off the session lock.
AnalysisSession::with_compressed_sources keeps every stored source text LZ4-compressed (files under 512 bytes stay plain), decompressed on read. Off by default, since a one-shot run reads each text many times. In php-lsp on Symfony (17,400 files) it cuts memory by about 75 MB after a first start and 80 MB after a restart, for under 1 s more CPU per start.
Changed
A call argument that violates the @template T of Bound of the parameter it is passed to (a parameter typed T itself) is reported under the argument kinds, as Psalm does, instead of InvalidTemplateParam: ArgumentTypeCoercion when the value is wider than the bound and may still fit (a runtime string for T of literal-string|int, a Node for T of Element), InvalidArgument otherwise. A template nested in the parameter type (array<T>, class-string<T>) is still InvalidTemplateParam.
SourceFile's salsa field is contents: SourceText: SourceFile::text(db) still returns the text, and SourceFile::new/set_contents take a SourceText (SourceText::from an Arc<str> or &str).
Performance: analysis-cache entries are held LZ4-compressed and decoded on read, with one shared table of reference symbols; cache.bin stores them the same way, so it loads and flushes without re-encoding entries. On Symfony the cache file drops from 13 MB to 8 MB, and php-lsp's memory after a first start drops by about 205 MB together with the next entry. The cache from an earlier mir build is discarded.
Performance: a warm pass over files with an analysis cache (AnalysisSnapshot::warm_files) no longer keeps each file's analyze_file and infer_scope memos, which only an edit's re-analysis reads.
Workspace and internal crate versions were updated to 0.101.0.
Fixed
A call to a docblock @method in a strict_types file is checked like a call from a non-strict file, since __call / __callStatic receive the arguments as an array and never throw a TypeError: a float for an int parameter is ImplicitFloatToIntCast instead of InvalidArgument.
A shape returned for a declared shape has its scalar and plain-object values checked on the keys both have: return ['a', 'b'] for @return array{0: int, 1: int} is InvalidReturnType. Missing keys and array, list or generic values are not judged.
self::A or Foo::BAR as an unkeyed item of a shape (array{self::A, list<self::B>}) is the item's type instead of a key named self.
% and %= are typed int for float and numeric-string operands instead of int|float, since PHP casts both operands to int.
A Cls::MODE_* docblock type is a valid arithmetic and bitwise operand ($mode & Cls::MODE_GET): it is the matching constants' values instead of InvalidOperand.
clone $this in a class whose private __clone() comes from a trait is no longer InvalidClone.
define(__NAMESPACE__ . '\NAME', …) declares the constant in the current namespace instead of being ignored.
do { … } while (true) is an infinite loop like while (true): a function that returns from it and never breaks no longer falls through to an implicit void return.
Inside a PHP_VERSION_ID check that only versions newer than the configured one pass (PHP_VERSION_ID >= 80400 on 8.3), methods, functions and classes added in those versions are no longer UndefinedMethod, UndefinedFunction or UndefinedClass.
A class named in an object{…} shape is resolved against the namespace and use imports instead of being read as a global class.
A docblock Generator, Closure or other bare built-in class name in a namespace that declares a class of that name is the local class on untyped @var properties and on @param types seen from a call site, as it already was elsewhere.
A Stringable object returned for a string return type in a file without strict_types is an info-level ImplicitToStringCast, as PHP casts it by __toString(), instead of InvalidReturnType.
@psalm-suppress InaccessibleProperty and ImpurePropertyAssignment suppress ImmutablePropertyModification, ImpureStaticProperty suppresses ImpureStaticPropertyAccess and ImpureStaticPropertyAssignment, and UndefinedPropertyFetch, UndefinedPropertyAssignment and their UndefinedThisProperty* forms suppress UndefinedProperty.
A @psalm-suppress on a class, interface, trait or enum docblock covers its whole body, as one on a function does, instead of only the declaration line.
new X in a @psalm-pure function is no longer ImpureFunctionCall when X is @psalm-immutable or its constructor is @psalm-external-mutation-free.
A polyfill that redeclares a pure built-in (str_contains(), mb_strlen()) is as pure as the built-in when called from a @psalm-pure function.
@phpstan-assert-if-true X $this (and the -if-false and @psalm- forms) narrows the receiver like instanceof X, intersecting an interface with its class instead of replacing its type, and also applies to a receiver an earlier check left as a union of classes inheriting the method.
An instanceof check on a property path deeper than $a->b ($a->b->c, $args[1]->value, $m->stmts[0]->expr) narrows later reads of that path until part of it is written, instead of being dropped.
throw throw $e is no longer InvalidThrow 'never'.
stream_filter_append() and stream_filter_prepend() accept params: without mode: the stubs' $params has its default.
trigger_error() and user_error() with E_USER_ERROR never return, so a variable assigned only before them is no longer PossiblyUndefinedVariable afterwards.
A sentence-ending dot after a @return type (@return void.) is no longer read as part of a class name.
extract() and array_multisort() accept a non-variable array (extract(f())) instead of reporting InvalidPassByReference, since PHP passes it by reference only when it can.
get_object_vars() returns array<string, mixed>, so its keys are no longer int|string.
parse_url($url, PHP_URL_HOST) and the other PHP_URL_* components return string|null|false (int|null|false for PHP_URL_PORT) instead of including array.
$mixed & $string (and |, ^) is int|string instead of int, since the mixed operand may be a string too.
Concatenating lowercase-strings, or one with a literal that has no uppercase letters (strtolower($c) . '::m'), is a lowercase-string (likewise uppercase-string) instead of a plain non-empty-string.
A truthy $x?->m() makes $x non-null, so if (!$x?->m()) { throw … } no longer leaves $x nullable afterwards.
A readonly property's element passed to a method on mixed ($m->dispatch($r->context['e'])) is no longer a ReadonlyPropertyAssignment.
A non-empty-string or non-falsy-string class name ($class . 'Query') is a valid new or :: receiver instead of InvalidStringClass, as a plain string already was.
A variable assigned inside a property fetch's receiver or offset in the right operand of && ($n > 0 && $d[$i = $n - 1]->p > 0, $a && ($e = f())->p) is defined in the truthy branch instead of PossiblyUndefinedVariable.
print_r($v, true) and var_export($v, true) are pure, since they return the dump instead of printing it.
reset() and end() on a property are no longer writes to it (ImmutablePropertyModification, ImpurePropertyAssignment), since they only move the internal pointer.
Appending to a @psalm-readonly (docblock) array property in its own constructor is no longer ReadonlyPropertyAssignment.
A static property's narrowing survives a call to a same-class static method whose body writes no property (self::$cache = […]; self::helper(); return self::$cache;), as it already did for $this methods.
A method missing on one member of a union that also holds an unknown class (Ex|Missing) is PossiblyUndefinedMethod instead of an UndefinedMethod error, since the unknown class may declare it.
$obj::CONST on an object of an unknown class no longer adds an UndefinedConstant to the UndefinedClass already reported for it.
An object offset on a mixed container (static $map; $map ??= new WeakMap(); $map[$obj]) is no longer InvalidArrayOffset, since the container may be an ArrayAccess object.
Destructuring a nullable or falsable array ([$a, $b] = f() with array{A, B}|null) gives nullable targets instead of the element types alone.
An override without a docblock inherits a parent's @param T through the class's @implements Runner<Concrete> / @extends binding, so its native Handle $h is read as the bound WinHandle.
A template named in an object{…} shape property (object{key: T}) is the template instead of a class named T, so its bound applies (an int|string bound is a valid array offset).
A string passed for a template bounded by int|float in a file without strict_types is InvalidScalarArgument, as for a plain int|float parameter, instead of InvalidArgument.
A method template bounded by a class template that the call leaves unbound (@template R of TResponse called statically) is checked against the class template's own bound instead of rejecting every argument as not a TResponse.
Calling a method of a @psalm-immutable class on a parameter in a @psalm-pure or @psalm-external-mutation-free function is no longer ImpureMethodCall, since such methods are checked as mutation-free.
[$obj, 'method'] with an intersection-typed $obj (Coll&Sel) is callable instead of InvalidArgument.
unset($a[$k]) drops the non-emptiness of a non-empty-array or non-empty-list variable, so a later array_shift() result may be null again.
A property passed by reference to a function (array_shift($o->extra)) loses a narrowed non-emptiness, so a later array_shift() result may be null again.
array{} joined with a non-empty-list<T> or non-empty-array<K, V> is list<T> / array<K, V> instead of the non-empty type, so the empty case is no longer lost (RedundantCondition on if ($keys)).
count($l) === N (and !== N on the false side) narrows a list<T> to the sealed shape array{T, …, T} of N elements, for N up to 8, so it satisfies a array{T, T} parameter.
T::class (or Foo::class) in a docblock is the class string of that template or class instead of a class named T::class.
A subclass of a concrete built-in class is no longer asked to implement interface methods the built-in provides, such as SplObjectStorage::seek() under PHP 8.1–8.3, where the stub marks it as added in 8.4.
A generic object argument whose type argument is unknown (new ArrayIterator($docblockArray), ArrayIterator<int|string, mixed>) for a more specific generic parameter is ArgumentTypeCoercion instead of InvalidArgument.
A literal key written to an untyped array known to be non-empty (after an empty() check) is read back with the written type instead of mixed.