fix(deps): update all non-major dependencies #20
Loading…
Reference in a new issue
No description provided.
Delete branch "renovate/all-minor-patch"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
3.12-slim-bookworm→3.13-slim-bookworm7.3.0→7.24.17.25.1(+1)Release Notes
vimeo/psalm
v7.24.1Compare Source
What's Changed
Fixes
Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.24.0...7.24.1
v7.24.0Compare Source
Features
T&array{id: int}is the type the template takes, with the keys of the shape added. A function can return what it was given plus new keys, and a param can require keys of a templated array. Psalm reported such an intersection asInvalidDocblockbefore. (#15231, @orklah) See Intersection types.*anywhere in a class constant mask (self::*_ACCESS), not only at the end.self::andstatic::in the@templatebound of a method:self::is the class the method is declared in (the using class for a trait method) andstatic::the receiver's class. Psalm resolved both against the calling class, so$c->get(2)for@template B of self::REF_*was anInvalidArgument....<V>or...<K, V>after their fields, and shapes without fields:array{id: int, ...<string>}InvalidDocblockarray{id: int, ...<array-key, string>}array{...}array<never, never>array<array-key, mixed>list{...<string>}array<never, never>list<string>?right after an operator:?A&?BisA&B|null(wasA|null),(A|?B)[]keepsB|null, and(T is ?int ? A : B)parses.??intis anInvalidDocblock.enum-string<HasLabel>accepts only enums: passingPlain::classof a class implementingHasLabelis anInvalidArgument.int-mask-of<1|2|4>is0|1|2|3|4|5|6|7, keywords work as shape keys (array{covariant: int}), and an extra type argument (key-of<array<int, string>, int>) is anInvalidDocblockinstead of being dropped.Foo::$m()and$foo->$m()when$mholds one or several known strings. The call returns what those methods return and is checked like a direct call. (#15220, @orklah) A first-class callable on several classes,($flag ? A::class : B::class)::make(...), is a closure of either method instead of onlyB::make().Performance
SqlWalker::walkSelectClause()analysed its inner loop 43 times instead of 23. (#15365, @orklah)isset()-guarded properties only when the constructor returns early. (#15327, @orklah)Fixes
Crashes
array_filter(),array_find()and their siblings called with only a namedcallback:argument no longer crash withUndefined array key 1. (#15288, @jirkace)nullto the receiver of its method call ($h->foo($h = null)) no longer crashes Psalm. An argument that assigns a nullable value no longer narrows the receiver, so a later$h->get()is aPossiblyNullReference. (#15367, @jirkace)@template T of string = self::Awithconst A = self::A) is reported asCircularReferenceinstead of crashing Psalm. (#15321, @jirkace)Narrowing and reported issues
Foo|Bar) applies the@psalm-assert-if-trueof one class's method only if the other class's method asserts it too. (#15220, @orklah)defined('ZipArchive::CREATE'),ZipArchive::CREATEis noMissingExtensionRequirement. (#15315, @jirkace)ReferenceReusedFromConfusingScopeis reported for a variable a loop detached from a reference, after it was released and bound again in another loop. (#15331, @orklah)Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.23.0...7.24.0
v7.23.0Compare Source
Features
array{type: "card", last4: string}|array{type: "bank", iban: string}as two shapes instead of merging them intoarray{iban?: string, last4?: string, type: 'bank'|'card'}, so a check of one key tells which other keys are there. Comparing a tag,isset(),array_key_exists(),count()andswitchpick the shape. (#15156, @jirkace) Unsealed shapes, unions of more than 8 shapes, and a shape union whose offset is written or unset are still merged into one shape.in_array()narrows the array: checking for a single known value (null,true,false, a scalar literal or an enum case) narrows the haystack. (#15152, @rvyyv-n) A loosein_array(null, $names)also rules out'', which is loosely equal tonull:$namesbecomeslist<non-empty-string>.array_walk()andarray_walk_recursive()callbacks are checked against the values, keys and extra argument the functions pass them. (#15167, @backendArchitect)@psalm-overloadon constructors:newis checked like a method call. The overload the arguments fit binds the class templates, and arguments that fit no signature are reported against the last overload. The return type of an overload is not used. See@psalm-overload. (#13355, @jirkace)Performance
matchwith more arms thanmaxShapedArraySizeno longer takes cubic time in the number of arms: 400 arms of an enum take 1.5 s instead of 30.5 s, and 753 arms 2.4 s instead of 184 s. (#15161, @jirkace)$a + $aon 250 literals takes under a second instead of 25 s. (#15171, @orklah)Fixes
Crashes
key-of<TArr>of a template bounded by another template no longer crashes withcount(): Argument #​1 ($value) must be of type Countable|array, null givenwhen the template has no lower bound (an untyped closure param). (#15212, @jay23606)Narrowing and reported issues
isset()and??on an array offset that always exists are reported as redundant:$a[0] ?? ""after$a = explode(",", $q)is aRedundantConditionGivenDocblockType. (#12633, @jirkace)is_*()orinstanceofcheck of a literal or a call result that can never hold is reported like one of a variable (is_string(123)is aTypeDoesNotContainType), andis_float(1)is aTypeDoesNotContainTypeinstead of aRedundantCondition. (#15221, @orklah)===of two arrays that can both be empty (list<int>andlist<string>), andinstanceofof a non-final class on an object shape, are no falseTypeDoesNotContainType, in a condition, amatcharm or a bare statement. (#15221, #15229, @orklah)(bool)oftrueorfalseis aRedundantCast, and a branch on a stored condition that is always true or always false is analysed as unreachable. (#15164, @orklah)$a !== $bagainst an object no longer narrows a wideriterableorcallable$awith a falseRedundantCondition. (#14364, @jirkace)__invoke(), may be callable:is_callable($handler)givesHandler&callable-objectinstead of aTypeDoesNotContainType. (#14455, @jirkace)!isList($x) || isMapInt($x), the negated array assertion keeps the non-array part of$x. (#14427, @jirkace)break, keeps its possibly undefined type after the loop instead ofmixed. (#15181, @orklah)[]that an unresolvablerequiremay fill is noEmptyArrayAccess. (#15189, @jirkace)Arrays
??=on a key missing from a sealed shape creates it:$e["b"] ??= 2givesarray{a: 1, b: 2}instead ofarray{a: 1, b: 2|mixed}with aMixedAssignment, and the key that is never set is aTypeDoesNotContainTypeinstead of anInvalidArrayOffset. (#14573, @jirkace)isset($l[$i])with$iof2|5, only the list items up to index 2 are required, so$l[4]is aPossiblyUndefinedArrayOffset. (#15173, @orklah)$d[$k] = [1]) leaves the values of the other keys possibly empty, soempty($d[$j])is noDocblockTypeContradiction. (#15184, @orklah)isset()check of it is aPossiblyUndefinedArrayOffset. (#15219, @orklah)["user" => $users[]] = $row) assigns it like=: the array gets the item, the property's type is checked, and taints flow to it. (#14544, @jirkace)Types and templates
pow(rand(0, 1) ? 2 : 3, 2)is4|9(was4), andround(1.234, getInt())isfloat(wasfloat(1)).T[K]with a key of'a'|'b',get_class($o) === $cwith a union of class strings, andgetAttributes()of a union of attribute classes use each of them. (#15157, @orklah)'Class::method'string, directly or throughcall_user_func()andcall_user_func_array(), returns what the method returns instead ofmixed. (#14511, @jirkace)$o->{$p}with$pof'x'|'y') has the type of each property instead ofmixed. (#14547, @jirkace)MixedArgumentTypeCoercionfor an untyped closure param passed to a method of a receiver likestatic<int, TKey>, or for a method template bounded by a class template (TA of array<TKey, TValue>). (#15183, @orklah)ArgumentTypeCoercionis reported again for an argument built in place (new Coll([new A()])) that breaks the bound of a method template, as for functions. (#15214, @orklah)staticin an intersection stays bound to its receiver:B<static>&staticon a final class isB<F>&F, and a call onstatic&Ino longer nests the receiver inside itself. (#15215, @orklah)Animal::classis aPropertyTypeCoercionfor aclass-string<T>withT of Animal, sinceTmay be a subclass. (#14625, @jirkace)Card&object{last4: string}fitsobject{brand: string, last4: string}. (#14458, @jirkace)Docblocks
namespace\Userin a docblock resolves to the current namespace, not a sub-namespace callednamespace. (#15177, @alies-dev)@returnnamed like a param of the function (Closure(int &$count): voidonf(int $count)) is no longer read as that param: noInvalidDocblock, and&is kept. (#15178, @alies-dev)@varaccepts a conditional on a param (($f is null ? T : int)), like@return. (#14501, @jirkace)int-mask<>of a wildcard global constant (PHP_URL_*), a generic constant or an intersection of constants is anInvalidDocblockinstead of a mask of0or of the first name. (#15022, @MikeFTV)Classes, properties and traits
parent::class,parent::CONSTandparent::$propin a trait are those of the using class's parent instead of aParentNotFound. (#15015, @jirkace)@propertyof the same name that describes magic access. (#15210, @orklah)interface_exists()of a missing interface, and declared again in theelse, is noUndefinedClass. (#15199, @orklah)@psalm-internalclass that uses it is noInternalClassorInternalMethod. (#14374, @jirkace)@internal,@psalm-internaland#[Psalm\Internal]on a promoted constructor property reportInternalProperty. (#15013, @jirkace)Purity
$clear(); return $owner->getChild();is aNullableReturnStatement. (#15046, @shu-chen-dot-ca)Taint analysis
MongoDB\BSON\ObjectId,UTCDateTimeand the other BSON values the driver stores as their BSON type don't carry thenosqltaint.Regex,Javascript,Document,PackedArrayand userland BSON implementations keep it. (#15099, @danog)mixedvariable narrowed by anifthat otherwise leaves (if (!is_scalar($v)) return;) no longer gets back the taints the narrowing removed. (#15163, @danog)strval(),implode()andvsprintf()of an object carry the taints of what its__toString()returns. (#14452, @jirkace)@psalm-taint-sinkwhen the parent it inherits docblock types from has templates. (#14504, @jirkace)Stubs and extensions
SoapClient::__setLocation()takes and returns?string. (#15010, @jirkace)MissingExtensionRequirementis not reported for an extension that a declared one requires (libxmlforext-dom,pdoforpdo_sqlite). (#15182, @orklah)Messages
PossiblyFalseArgumentsayspossibly false value provided, likePossiblyNullArgument. (#15151, @ARAYN7011)CLI and config
phprequirement incomposer.json, Psalm analyses the version of itsconfig.platform.phpinstead of the running PHP version. (#15179, @orklah)**path pattern no longer follows a symlink cycle until it fails withCould not resolve config path. (#14559, @jirkace)Plugin API
Union::isBool()is true when every member is aTBool, likeisInt()andisString():trueandfalsealone are nowbool. (#15164, @orklah)Union::isSingle()is deprecated and will be removed in Psalm 8: it takes1|2for a single type, sogetSingleAtomic()returns its first literal. UseisSingleAtomic()beforegetSingleAtomic(). (#15157, @orklah)AfterMethodCallAnalysisgets theStaticCallthe user wrote for a static call to a@mixin, or to an instance method throughself::/static::, instead of aVirtualMethodCall. (#15216, @orklah)Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.22.1...7.23.0
v7.22.1Compare Source
What's Changed
Fixes
Internal changes
TNamedObject::setValueIsStatic()ignoring$is_static_resolvedby @orklah in #15127Full Changelog: https://github.com/vimeo/psalm/compare/7.22.0...7.22.1
v7.22.0: Call-site varianceCompare Source
New AI, UX and
@templatesyntax features.Features
covariantorcontravariantbefore a type argument makes one param accept a generic of any subtype (or supertype) of it, without changing the class's template. As withBox<*>, values then go one way only: from aBox<covariant Node>you readNode, but can't put anything in. (#15096, @alies-dev)psalm --explain=<issue>prints an issue's documentation (what it means, an example, how to fix it) from the installed version, offline and without a config. It takes the issue type, its shortcode or its psalm.dev link. (#15066, @alies-dev, @roxblnfk)CLAUDECODE,CURSOR_AGENT,CODEX_THREAD_ID,AI_AGENT, …), it prints thecompactformat (one line per issue), no progress output even ifCIis set, a one-line result (also0 issues), and[*]after each issue--altercan fix. An explicit--output-formatwins, and nothing changes outside an agent. See AI agents. (#15068, #15069, #15067, @alies-dev)--no-taint-analysisskips taint analysis for one run (runTaintAnalysisis on by default), e.g. for a quick local check (#15078, @orklah).InternalFunctionfor a call of an@internalor@psalm-internalfunction from outside its namespace. (#15084, @orklah)ParseErrorfor constructor property promotion when analysing PHP 7.x. (#15086, @orklah)--alteron PHP 8.2 writestrue,falseandnullas native types (: true|nullinstead of: bool|nullplus a docblock), and no longer adds docblocks that repeat a native type. (#15083, @orklah)Performance
Fixes
Taint analysis
TaintedCallablefor a tainted method name:$object->$name(),A::$name(). (#15072, @alies-dev)strip_tags()with allowed tags is not an html escape:strip_tags($_GET["x"], "<a>")isTaintedHtml. (#14753, @arpitjain099)Stubs and plugins
@return(or its own@psalm-overload) replaces the original's@return $thisand overloads, so a stubbed call returns the stub's type again (a 7.19.0 regression). (#15090, @alies-dev)MethodSignatureMismatchfor an override that widens a param of a stubbed userland class, andfloat/intswaps PHP rejects are reported. (#15114, @orklah)[]onDs\Map,Ds\Vectorand other Ds collections is typed and checked, and a stub class that leaves out a method of its interfaces still has it. (#15039, @orklah)nullkeeps the function's params checked. (#15040, @orklah)[$this, 'method']:CallAnalyzer::getFunctionIdsFromCallableArg()takes the call'sContext. (#15082, @orklah)@mixinfor a method behind__call()/__callStatic(). (#15020, @shu-chen-dot-ca)Arrays and narrowing
isset()and!isset()on array offsets: a negated check drops the shapes that always have the offset and keeps the optional offsets it leaves; an empty array stays empty; a nestedisset($a["x"][3])narrows$a["x"]. (#15103, #15104, #15105, #15076, @orklah)switchcase is analysed knowing the cases before it didn't match. (#14528, @jirkace)mixedfallback keeps that key's type. (#14815, #14611, @jirkace)is_int(),is_bool()andis_string()keep the emptiness ofempty-scalarandnon-empty-scalar. (#14431, @jirkace)is_callable()on a list can be true. (#14319, @jirkace)MixedAssignment/MixedArgumentin aforeachover an always-empty list, such aslist<T>of anewcovariant generic. (#15095, @alies-dev)Types and templates
value-of<T>of a backed enum template is an array key, and$case->valueof aTis avalue-of<T>. (#14618, @jirkace)Card&object{last4: string}&object{brand: string}). (#14457, @jirkace)staticin the params of a@methodtag resolves to the called class. (#14480, @jirkace)void|neverisvoid, notnull:AssignmentToVoidis reported, and an always-exiting function is noInvalidReturnType. (#15087, @orklah)pow()with a zero and a float operand is a float. (#14845, @ARAYN7011)PHP_INT_MINis negative,PHP_DEBUG/PHP_ZTSare0|1(boolsince PHP 8.4), and$_SERVER["DOCUMENT_ROOT"],["SCRIPT_FILENAME"]and["PATH_TRANSLATED"]can be empty. (#15079, #15092, @orklah)get_object_vars()doesn't include static properties. (#15011, @jirkace)Functions, classes and properties
PropertyNotSetInConstructorfor a redeclared promoted property or one assigned through$this->$name. (#15038, @orklah)NonInvariantPropertyType. (#14623, @jirkace)$thisit writes, and a by-reference capture gets what the closure leaves in it. (#15048, #15052, @danog)ReferenceConstraintViolationfor a reference rebound before abreakor in aswitchcase. (#13710, @jirkace)MismatchingDocblockReturnType. (#13213, @jirkace)InvalidReturnTypeon PHP 8.1+. (#15081, @orklah)global $xin a function has the type declared in<globals>. (#15116, @orklah)Scanning and includes
requireof a ternary between two paths is resolved, and the files a dependency requires through one are scanned (Carbon 3'sCarbonPeriod). (#15094, @bardrop; #15080, @orklah)ssh2_*functions belong to ext-ssh2, not ext-swoole. (#15106, @orklah)CLI and config
src/C3.php changed while Psalm was running. Run Psalm again.instead of a crash, and a worker crash is printed once. (#15061, @alies-dev)-cwith a directory or an empty path reportsCannot read the config fileinstead of crashing. (#14947, @tlq5l)config.xsdacceptsallowMissingFileson<projectFiles>,<extraFiles>and<errorLevel>. (#15037, @orklah)Docs
allowMissingFilesand the*/**path patterns. (#15037, @orklah)SecurityIssuein<unsuppressibleIssues>keeps every security issue reported. (#15074, @danog)Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.21.1...7.22.0
v7.21.1Compare Source
Fixes
Taint analysis
foreachwrote back under their keys reaches a cast. (#14965, @orklah)f(...[safe(), $_GET['x']]),$firstis no longer tainted. (#14979, @shu-chen-dot-ca)array_walk()andarray_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]andproperties-of<T>resolve whennewbinds the template:(new ReflectionClass(new stdClass()))->getName()isclass-string<stdClass>. An inheritedself<T&C>assertion narrows a subclass again. (#14981, @orklah)properties-of<T>over several classes includes the properties of each. (#14982, @orklah)class-string<T>|Tparam given a class string bindsTto the class only, without a falseIncompatibleTypeParameters. (#14994, @orklah)@template T of staticcalls a method returningTon$thisorstatic::. (#14978, @shu-chen-dot-ca)Narrowing, loops and arrays
$x != ""and$x != 0removenulland the loosely equal bool from$x. (#14995, @orklah)foreachover a non-empty list assigns before everybreakis defined after it. (#12439, @jarstelfox)extract()a variable assigned on one path is no longer read as possibly undefined. (#12442, @jarstelfox)PossiblyUndefinedVariableon$r?->m() ?? [], orTypeDoesNotContainNullon$r?->p ?? [], when$rmay be undefined. (#14998, @orklah)foreachkey,array_key_last()) keeps its shape. (#15009, @orklah)$a + [...]combined with a shape: no falsePossiblyUndefinedArrayOffseton keys both declare, and noInvalidArgumentwhen it is passed to a sealed shape param. (#15002, @orklah)DOMNamedNodeMap,Dom\NamedNodeMap,Dom\NodeListandDom\HTMLCollectionare read by position or name instead of reportingInvalidArrayAccess. (#14535, @jirkace)Properties and constructors
$object::$propis checked as a static fetch on the object's class, so undeclared and instance-only properties reportUndefinedPropertyFetch. (#12046, @HenkPoley)MissingConstructorfor a subclass inheriting the real constructor of a class a stub declares without one, and noPropertyNotSetInConstructorafterAncestor::__construct(). (#15001, @orklah)@psalm-suppress UndefinedConstantapplies to constants in docblock types (@var int-mask<NO_SUCH_CONSTANT>). (#13540, @alies-dev)Purity
DateTimeandDateTimeImmutableconstructors require only thetimecapability, and theDateIntervalconstructor is pure. (#14962, @jirkace)Stubs
CURLFOLLOW_ALL,ETH_P_ALL,PHP_BUILD_DATE, …) are declared. (#13019, @alies-dev)DateInterval::createFromDateString()no longer returnsfalseon PHP 8.3+. (#11849, @xelaris)SQLite3Result::columnName()can returnfalse. (#11819, @stof)ReflectionObjectis generic, likeReflectionClass. (#11774, @Kenny1911)Language server and
--alter--alterwrites only native types the analysed PHP version supports (noobjectbelow 7.2) and writesint|stringforarray-keyfrom PHP 8.0. (#14933, @orklah)Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.21.0...7.21.1
v7.21.0Compare Source
Features
HttpClientInterface::request()is an SSRF sink. (#14950, @danog)strtolower()andstrtoupper()of literal strings return literals:strtoupper(rand(0, 1) ? "get" : "Post")is'GET'|'POST'. (#14628, @jirkace)Performance
Generator::send()calls only through nodes a generator flows into: 17 s to 10 s for that step on a ~5,600-file codebase. (#13504, @jarstelfox)Fixes
Taint analysis
ENT_QUOTES,JSON_HEX_TAG) stay known when a library callsdefine()with a dynamic name, so the escaping they ask for is kept. (#14949, @danog)Assertions and narrowing
@psalm-assert-if-trueand@psalm-assert-if-falseof a remembered call apply when the call is compared withtrueorfalse. (#14605, @jirkace)($s .= "a") === "1a") narrows the variable it assigns. (#14532, @jirkace)TypeDoesNotContainType. (#14609, @jirkace)isset()on a sealed array with a template offset bounded by the array's keys is no longer anInvalidArrayOffset. (#14603, @jirkace)Types and templates
callable-objectno longer fits an object shape or acallable-objectof another signature. (#14929, @MikeFTV)newleft unbound is checked against constraints naming other templates of the class (IncompatibleTypeParameters). (#12443, @jarstelfox)Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.20.0...7.21.0
v7.20.0Compare Source
Features
@psalm-overload: gives a function or method several signatures, and a call returns the result of the first one its arguments fit. See@psalm-overload. Constructors are not supported yet. (#13353, #13354, @jirkace)@psalm-database-query ... readonlymarks a method that can only run reading queries, so its queries Psalm can't parse store nothing. See the annotation. (#14860, @danog){name}and{name:Type}query parameters are stored, clauses after the tables of aSELECTare parsed,INSERT ... FORMATstores its data in the listed columns, andALTER TABLE ... UPDATEstores likeUPDATE. (#14854, #14859, #14857, @danog)sprintf()with a literal format is parsed, and a query in a variable ($sql . " LIMIT 1") starts with what the analysis knows of$sql. (#14858, #14856, @danog)realpath()result checked to start with a directory is not a path traversal, and a path that starts with a directory is not an SSRF target. (#14171, @danog)Codebase::addTaintedCall()adds calls that PHP code doesn't make (a Twig template calling a filter) to the taint graph, andAddCallTaintsInterfaceandRemoveCallTaintsInterfacehandlers run for these calls, which have noExpr. (#13658, @danog)Fixes
Taint analysis
json_decode(),html_entity_decode()) give back the taints that the escapes before them removed. Escape flags with a variable operand, or flags a call may have changed, no longer count as escaping. (#13642, @danog)Types
non-falsy-stringpassed as acallable-stringreportsArgumentTypeCoercion. (#14925, @orklah)UnsafeGenericInstantiationfornew staticwhenstaticis only an array shape key in the return type. (#14920, @orklah)@psalm-assert iterable&CountablekeepsCountable, and intersections are compared by every part. (#14944, @orklah)$int & <non-negative int>is bounded by the non-negative operand:$i & 0x0Fisint<0, 15>. (#14507, @jirkace)callable-array. (#13424, @jirkace)T&Stringablecasts to string whenTis bounded byobjector unbounded, and the cast charges__toString()in pure code. (#14471, @jirkace)class-string-mapcombined into another array has its template replaced by its bound, andclass-string-map<T of Foo, T>keeps its bound in a namespace. (#14934, @orklah)list<int>, notarray). (#14923, @orklah)Templates
@implementsargument, without a falseMoreSpecificImplementedParamType. (#14459, @jirkace)non-empty-string, notarray|non-empty-string). (#14582, @jirkace)Narrowing, loops and arrays
$xafter$t = gettype($x)unlinks$t, soswitch ($t)no longer narrows the new$xtonever. (#14937, @orklah)$x === $ywith$yone of several class-strings keeps all of them. (#14938, @orklah)!array_is_list()of a value that is always a list reportsTypeDoesNotContainType. (#14529, @jirkace)isset($array[$id])with astring$idon an array with int keys is not anInvalidArrayOffset. (#14652, @jirkace)fororwhileloop whose counter starts beyond every value of an int bound (for ($i = 1; $i <= $size; $i++)with$size: int<1, max>) is always entered. (#14543, @jirkace)do/whilecondition on an offset of amixedvariable no longer holds after the loop. (#14584, @jirkace)??accepts any left side (null ?? 1, a constant, an operation) withoutInvalidArgument, and drops itsnull. (#14591, @jirkace)rememberPropertyAssignmentsAfterCall="false", refinements of readonly properties survive calls. (#14571, @jirkace)Classes, properties and constants
static::or an object of a non-final class, has that type instead ofmixed. (#14596, @jirkace)selfin the type of a trait property resolves against the class using it,staticin an inherited property type against the class read, andget_object_vars()resolves template-bound literals. (#14512, @jirkace)PropertyNotSetInConstructor. (#14566, @jirkace)if (!class_exists(...)), a function body) in a namespaced file are analysed. (#13654, @danog)autoloadalso loads is no longer treated as unshipped becauseautoload-devmaps it too. (#14936, @danog)--alterproperties-of<T>is written as a nativearray. (#14930, @lyn1dev)non-empty-string) gets a docblock, and enums and anonymous class parents get the right namespace. (#14917, @orklah)[]or inside an intersection is parenthesised. (#14921, #14935, @orklah)Internal changes
Atomic::getId()no longer falls back togetKey(), so a plugin type that extendsAtomicmust write its id or it throws aLogicException. (#14922, @orklah)New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.19.0...7.20.0
v7.19.0Compare Source
Features
@phpstan-sealedis read like@psalm-inheritors. (#11818, @stof)composer.jsonrequires any Symfony package, not onlysymfony/framework-bundle. (#14682, @danog)ensureOverrideAttributealso reportsMissingOverrideAttributefor a property (PHP 8.5), class constant or enum case (PHP 8.6) that overrides a parent member. (#14407, @jirkace)UndefinedPropertyFetchorUndefinedPropertyAssignmenton a property declared by@propertyin a class without__get()/__set()says to add the magic method or setusePhpDocPropertiesWithoutMagicCall="true". (#14644, @jirkace)@psalm-traceworks on static properties (self::$name). (#14629, @jirkace)Fixes
Narrowing and conditions
==keeps the values PHP juggles:"1" == 1,1 == 1.0,false == [],$stringable == "a". (#14906, @orklah)== 0keeps thefalseandnullloosely equal to it, so($h = fopen(...)) == 0is no longer aParadoxicalCondition. (#14823, @orklah)isset()on an offset of a possibly-nullmixednarrows in anelseifas in anif. (#14393, @orklah)match (false)narrows the variables of its conditions. (#14354, @jirkace)$item?->flag !== true,$itemis not null. (#14460, @jirkace)instanceofkeeps what is known of its properties. (#14537, @jirkace)!array_key_exists($key, $array)on a generic array says nothing about$key. (#14613, @jirkace)stringorintcan be identical tokey-of<T>orvalue-of<T>of a templateT of array. (#14437, @jirkace)instanceof UnitEnumorBackedEnumexcludes classes that aren't enums. (#14526, @jirkace)($a['k'] ?? false) && ...establishes that the key is set. (#14377, @jirkace)isset()and??on a magic property are not decided by the type of__get()(SimpleXMLElementchildren). (#14363, @jirkace)ParadoxicalConditionon a clause about a variable that a nested loop writes. (#14899, @orklah)ifwhose condition on an array offset always holds no longer makes the key optional. (#14896, @orklah)isset()in anifkeeps the same type as without it. (#14893, @orklah)RedundantConditionorTypeDoesNotContainType. (#14822, @orklah)empty()of a possibly undefined bool is not anInvalidArgument. (#14819, @orklah)MixedArrayAccessis reported when a!empty($p['a'])check is stored in a variable first. (#14824, @orklah)switch (true)overinstanceofchecks of final classes is not anInvalidReturnType. (#13362, @jirkace)Loops
whileorforloop whose condition holds on entry is always entered. (#14419, @jirkace)&&in aforcondition is defined in the body and the step. (#14827, @orklah)switchon a call doesn't stay in scope after it. (#14569, @jirkace)Arrays
$array + ['key' => $default]has the keys of the shape, and so does a shape plus an array. (#14621, @jirkace)$a[$k][$i] = $v) is non-empty. (#14404, @jirkace)$a[$k]++,$a[$k] += 1and by-reference arguments. (#14540, @jirkace)ArrayAccessobject no longer checks a wrong value againstoffsetSet(). (#14371, @jirkace)Templates and generics
foreach, array fetches and destructuring from a generic construction resolve their type variables. (#14897, @orklah)non-empty-listcondition. (#14830, @orklah)falserecords a bound on a type variable likenulldoes. (#14589, @jirkace)mixed. (#14592, @jirkace)newon a generic class keeps the template open when inherited public members can constrain it. (#14448, @jirkace)@propertyuses the template arguments of the parent. (#14530, @jirkace)$thiswith@psalm-this-outreturns the@psalm-this-outtype. (#14639, @jirkace)class-string<T>with@template T as array|objectis not anInvalidDocblock. (#11755, @vincent4vx)array<mixed>passed to aniterable<string>param is aMixedArgumentTypeCoercion, and conditional types such as($iterable is list ? never : list<T>)work again. (#13329, @andrew-demb)callable(never)hint no longer turns a typed closure param intonever. (#14447, @jirkace)I&staticin a final class implementingIis that class. (#14461, @jirkace)Classes, methods and constants
matchwhose every branch is$thisis$this, and so istap($this, $callback). (#14818, #14895, @orklah)PossiblyNullReferenceafter a call with arguments in a nested nullsafe chain. (#14850, @alies-dev)AmbiguousConstantInheritancefor a constant reached through a parent class and an interface. (#12663, @Aerendir)OverriddenPropertyAccesswhen a subclass redeclares a protected property of a native extension class. (#12052, @jturbide)PossiblyInvalidArgumentinstead ofInvalidArgumentwhen a member of the argument's union is a parent type of the param. (#14820, @orklah)int-mask-of<self::A_*>wildcard ignores constants that aren't integers. (#14348, @jirkace)Purity
DateTimeImmutable,PDO,Redis, …) is no longer treated as pure. (#14816, @orklah)strtr()replacements,array_multisort()with string flags and unpackedimplode()arguments charge__toString(). (#14451, @jirkace)curl_share_setopt(),imap_timeout()andimap_expunge()are impure. (#11858, @ThomasLandauer)Taint analysis
vprintf()format andcurl_setopt()options are read by param, also from named and unpacked arguments. (#14454, @jirkace)extract()of a sealed array is noTaintedExtract, and the variables it assigns carry the array's taint. (#14601, @jirkace)Stubs
urlencode()andrawurlencode()of anon-empty-stringare non-empty. (#14521, @jirkace)get_class()combined with other strings is anon-falsy-string. (#14355, @jirkace)Ds\Hashable::equals()takes$obj. (#14373, @jirkace)MissingExtensionRequirementis reported for them. (#14686, @danog)Messages
RedundantCast,InvalidArrayOffset,InvalidIterator, and any message that includes a union). (#14903, #14905, @orklah)MixedMethodCallnames the known type ofobjectand object shapes. (#14347, @jirkace)CLI, config and tools
--threads=). (#14336, @jirkace)psalm-refactorrejects destinations PHP reserves as class or constant names. (#14617, @jirkace)--alterkeeps string refinements (non-empty-string,non-falsy-string) in the docblocks it writes. (#14913, @orklah)Plugin API
FunctionParamsProviderInterfacehandler returning[]declares no params; returnnullto leave them unchanged. (#11622, @kkmuffme)Union::getKey()is deprecated and will be removed in Psalm 8: usegetId()to identify a type. (#14910, @orklah)Internal changes
StreamSelectDriverworker fork to 6.x. (#14839, @orklah; #14750, @zonuexe)New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.18.0...7.19.0
v7.18.0: Contravariant templatesCompare Source
Features
@template-contravariant(also@psalm-and@phpstan-template-contravariant): a template for a class that only takes values, such as a handler, writer or mapper. ASink<Animal>fits where aSink<Dog>is expected, not the other way round, and Psalm reports the template where the class gives a value out. Plugins read the variance withClassLikeStorage::getTemplateVariance(). See Template contravariance; the templated annotations page was rewritten with checked examples. (#14669, @alies-dev)--debug-performance(short name--profile) prints where a run spent its time and memory: stages, workers, the slowest files, statements and functions, and plugin handlers. With a path it also writes a JSON profile that you can drop on https://psalm.dev/profile/ to see it as charts; the page reads it in your browser and sends it nowhere. See Finding out why Psalm is slow. (#14737, #14769, #14807, @alies-dev)skills/psalmteaches AI coding agents to run Psalm, fix its issues, write annotations and editpsalm.xmlthe way the docs recommend. Install it withnpx skills add vimeo/psalm --skill psalm, with thellm/skillsComposer plugin, or by copyingvendor/vimeo/psalm/skills/psalminto your agent's skills directory. (#13152, @roxblnfk; #14751, @danog; #14795, @roxblnfk)Performance
Fixes
Templates and type variables
new Pipe(fn (int $x) => ...)with aClosure(T): voidconstructor param capsTatint, so a later$pipe->push('s')isIncompatibleTypeParametersinstead of reaching theintcallback. (#14669, @alies-dev)@template U of T) is reported in a param even after an earlier param usedUlegally. (#14669, @alies-dev)new Coll([1]), then$c->add('x')) see every value it holds, not only the construction-site ones. (#14551, @shu-chen-dot-ca)nullno longer fits a template without a bound:fn() => nullforcallable(): T,[null]forlist<T>. (#14550, @shu-chen-dot-ca)@use. (#13429, @jirkace)@implements Wrapper<static>resolvesstaticto the object it is read from, and chained calls on such a value no longer hang. (#14572, @jirkace)@return static<NewK, NewV>on a template receiver keeps its new type arguments. (#14579, @jirkace)ImplementedReturnTypeMismatch. (#14502, @jirkace)preg_replace()on an array ofStringablereturns an array). (#14421, @jirkace)Tread at akey-of<T>offset isvalue-of<T>. (#14586, @jirkace)is_int(),is_scalar()and similar checks narrow a template bounded byscalar,numeric,array-keyor an int range instead of reportingDocblockTypeContradiction. (#14545, @jirkace)class-string<T>. (#14365, @jirkace)Coll<*>) gives the template's bound instead ofmixed. (#14666, @alies-dev)@template, the variance and the declared order of templates instead of marking every template@template-covariant. (#14669, @alies-dev)Narrowing and arrays
$a !== $bwith several possible values of$bdoesn't exclude them all from$a. (#14525, @jirkace)isset($array[$k])with$kone of several literal keys,$array[$k]is the value of those keys. (#14646, @jirkace)$arr[$key]stays known to be set when$keyis narrowed insideif (isset($arr[$key])). (#13344, @jirkace)InvalidArrayOffsetis reported when an item is read again under an index narrowed to a key the array can't have. (#14767, @orklah)($a ?? null) !== nullassertsisset($a). (#14517, @jirkace)instanceofa parent class narrows to the parent class. (#14318, @jirkace)get_class()of a union of classes is the name of any of them. (#14366, @jirkace)V&object{x: string}) has the type of both. (#14546, @jirkace)ensureArray*OffsetsExist, an offset that may be one of several literals is set only when each of them is. (#14606, @jirkace)maxShapedArraySize. (#14641, @jirkace)"a\r\nb"). (#14600, @jirkace)'6e5212ed-…'in Symfony'sFormconstraint. (#14797, @leonardsimonse)pow()of two int literals is an int literal. (#14505, @MikeFTV)Control flow
continueorbreakis possibly undefined after the loop. (#14509, @jirkace)breakthat reassigned it. (#14456, @jirkace)&&are defined in the next operands of the enclosing&&. (#14409, @jirkace)throworexitin a branch returnsvoid, notnever. (#14793, @MikeFTV)return, so it is noUnusedFunctionCall. (#14562, @jirkace)Callables and nullsafe calls
?->in a chain are analysed with a non-null receiver, as PHP skips the whole chain when it is null. (#14608, @jirkace)?->apply where the call is truthy. (#14531, @jirkace)__invoke()is callable. (#14590, @jirkace)__call()is not anUndefinedMagicMethod. (#14411, @jirkace)staticin closure hints of calls in a trait on other objects resolves to that object. (#14446, @jirkace)Closureobject of unknown signature is aClosure. (#14599, @jirkace)yield fromforwards the send type of the inner generator. (#14340, @jirkace)Reported issues
nullorfalsewith the expected type isInvalidArgument, notPossiblyInvalidArgument, in closure params ofarray_map()and similar functions and in__set()calls on a@property. (#14742, @orklah)ParadoxicalConditionon a dead||operand next to other values of the same variable. (#14821, @orklah)ParamNameMismatchfor a name another overridden method uses. (#14536, @jirkace)MethodSignatureMismatchfor@no-named-argumentson parameterless methods. (#14799, @orklah)sethook is checked against the hook's param type. (#14538, @jirkace)array_column()reads are used. (#14560, @jirkace)@implementsnaming an interface the class doesn't implement gets the same message with or without type arguments. (#14650, @jirkace)@psalm-suppressbefore the expression ofechoor<?=is read. (#14527, @jirkace)Stubs
ini_get()of a core setting no longer includesfalse. (#14809, @alies-dev)intval(),floatval()anddoubleval()report what the casts report. (#14311, #14805, @jirkace)ArrayObject::offsetSet()andArrayIterator::offsetSet()accept anulloffset. (#14516, @jirkace)pgsqlextension stub with thePGSQL_*constants, and the classes of thegeosextension. (#14637, #14631, @jirkace)FILTER_THROW_ON_FAILUREis defined and has no failure value. (#14359, @jirkace)Redis::auth()andRedisCluster::__construct()accept phpredis ACL credentials. (#14800, @orklah)WeakMap,SoapClient,MemcachedandPDOStatementuse the PHP 8 param names. (#14353, #14367, @jirkace)Name::$partsand uses v5'sArrayItemfor array and list items. (#14514, @jirkace)CLI, config and tools
reportInfo="false"also dropsPossibly*issues that takeinfofrom their parent issue. (#14785, @alies-dev)console,phpstormandgithub, run statistics (--stats, the timing line, the--profilesummary) go to stderr. (#14745, @alies-dev)--update-baselinekeeps multi-line samples of CRLF files. (#14794, @ARAYN7011)MissingDependencyand four other issues. (#14649, @jirkace)--generate-stubskeeps the trait uses and the interfaces of a class with a parent. (#14564, @jirkace)@psalm-scope-thisis scanned. (#14565, @jirkace)psalm-refactorrejects reserved words as destinations. (#14552, @MohannadElemary)Internal changes
PluginTestworks with psalm/plugin-phpunit 1.3.3. (#14810, @orklah)FunctionLikeAnalyzer::getFunctionLikeNode()(#14635) andConfig::getPreloadedStubFiles()(#14633), @jirkace. Psalm now requires psalm/psalm-plugin-api 0.5.2. (#14846, @alies-dev)New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.17.0...7.18.0
v7.17.0Compare Source
What's Changed
Features
Fixes
Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.16.0...7.17.0
v7.16.0: Star projectionCompare Source
Features
Foo<*>: Kotlin's syntax for a generic argument you don't know. Reads go through the template's bound (Box<*>::get()isobjectforT of object), writes through it expectnever, andBox<*>accepts anyBox. See Star projection. (#13139, #13493, #14619, #14598, @alies-dev)Performance
||chains ofstr_starts_with(). Important for WordPress projects (#14653, @alies-dev)**entry already matched: 60 to 85 % faster with**/vendor-style entries. (#14624, @alies-dev)@methodtags: scanning up to 5 % faster on classes with hundreds of them, such as AWS SDK clients and Laravel Facades. (#14620, @alies-dev)Fixes
Templates
@extends Base<list<U>>,@extends Base<Box<TModel>>, also across two@extendslevels). (#14487 @jirkace, #14558 @alies-dev)newon a@template-covariantclass infersneverfor a template nothing can constrain, sonew Coll()fitsColl<int>. (#14449, @jirkace)Callables and invokable objects
__invokeis callable. (#14610, @alies-dev)array_map()with an invokable object as the callback infers the return type of__invokeinstead oflist<mixed>. (#14654, @alies-dev)Closureis expected is anArgumentTypeCoercion, not anInvalidArgument. (#14657, @alies-dev)Other
--find-references-tofinds the calls of a function. (#14648, @jirkace)Docs
Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.15.0...7.16.0
v7.15.0Compare Source
What's Changed
Features
Fixes
Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.14.0...7.15.0
v7.14.0Compare Source
What's Changed
Features
Fixes
Docs
Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.13.2...7.14.0
v7.13.2Compare Source
What's Changed
Fixes
Full Changelog: https://github.com/vimeo/psalm/compare/7.13.1...7.13.2
v7.13.1Compare Source
What's Changed
Fixes
Full Changelog: https://github.com/vimeo/psalm/compare/7.13.0...7.13.1
v7.13.0Compare Source
What's Changed
Features
Fixes
Docs
Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.12.0...7.13.0
v7.12.0Compare Source
What's Changed
Features
@optional-arguments-by-name,@arguments-by-nameand@stable-parameter-namesby @nicolas-grekas in #12389Fixes
sort()andarray_unique()when Psalm runs on PHP 8.6 by @alies-dev in #14201$xwhen$x ??= $yis compared with null by @orklah in #14282statickept on the union of $this and another object of its class by @shu-chen-dot-ca in #14078Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.11.0...7.12.0
v7.11.0Compare Source
What's Changed
Features
Fixes
Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.10.0...7.11.0
v7.10.0Compare Source
What's Changed
Features
falseoffset, which PHP turns into0by @jirkace in #12690--min-type-coverageto fail below a type coverage minimum by @alies-dev in #14075Fixes
non-empty-scalarand similar types in namespaces by @orklah in #14079empty-scalarandnon-empty-scalarno longer accept any scalar by @orklah in #14080do-while's first iteration, notPossibly*by @orklah in #14032foreachand references by @orklah in #14099mixedvariablemixedafter anifthat wrote its offsets by @orklah in #14039mixedvariablemixedafterelse,switch,matchand||by @orklah in #14063PossiblyUndefinedVariableafterisset($var[$k])by @orklah in #14065InvalidArrayOffseton nested writes by @orklah in #14062nullcomparisons toneverby @orklah in #14036instanceofchecks toneverby @orklah in #14048===between overlapping types by @orklah in #14037class_exists()narrows only inside itsifblock by @jirkace in #13391$a?->m() ?? falsenarrows$ato non-null by @jirkace in #12995__METHOD__and falseLessSpecificReturnTypeby @danog in #14066#[\Override]on class constants and enum cases by @alies-dev in #14038__toString()calls by @shu-chen-dot-ca in #13782filter_var(null)returns''by @orklah in #14124libxml_set_external_entity_loader()is not an unused call by @alies-dev in #14118pathinfo()may omitdirnameby @orklah in #14122proc_open()and others by @orklah in #14100SplObjectStoragevalue checks and param names by @orklah in #14121stream_get_meta_data()keys may be undefined by @orklah in #14095key-of<T>/value-of<T>instead of reporting contradictions by @orklah in #14041key-of<T>/value-of<T>in operations by @orklah in #14064key-of<T>/value-of<T>afterarray_key_exists()/in_array()by @orklah in #14034stringin anarray|scalarargument to astring|arraytemplate by @orklah in #14098Internal changes
ComplexMethodonIfElseAnalyzer::analyze()by @orklah in #14088unset()of an offset in anisset()branch by @jirkace in #13123New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.9.0...7.10.0
v7.9.0Compare Source
What's Changed
Features
Fixes
curl_multi_get_handles()returnsarray<array-key, mixed>instead oflist<CurlHandle>by @alies-dev in #14022socket_addrinfo_lookup(),socket_cmsg_space()andldap_free_result()by @alies-dev in #14023Internal changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.8.0...7.9.0
v7.8.0Compare Source
What's Changed
Features
markAllNonInternalCodeAsApifor libraries, and make the code a project doesn't ship internal by @danog in #13939Fixes
Full Changelog: https://github.com/vimeo/psalm/compare/7.7.0...7.8.0
v7.7.0Compare Source
What's Changed
Features
Fixes
helpby @MrYamous in #13744object{}of an intersection makes method calls mixed by @alies-dev in #13876Internal changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.6.0...7.7.0
v7.6.0Compare Source
What's Changed
Features
Codebase::addReportableFiles()to report issues in files Psalm doesn't analyze by @alies-dev in #13725Fixes
@mixinlookup order: own, traits, parents; first declared wins by @alies-dev in #13694$project_files) by @alies-dev in #13719__call()by @alies-dev in #13727Docs
addReportableFiles()in the plugin entry point by @alies-dev in #13728Internal changes
Other changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.5.0...7.6.0
v7.5.0Compare Source
What's Changed
Features
Fixes
--monochromeoption by @alies-dev in #13669Internal changes
Other changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.4.0...7.5.0
v7.4.0Compare Source
What's Changed
Features
Fixes
Other changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.3.2...7.4.0
v7.3.2Compare Source
What's Changed
Fixes
Internal changes
Other changes
Full Changelog: https://github.com/vimeo/psalm/compare/7.3.1...7.3.2
v7.3.1Compare Source
What's Changed
Fixes
NAN,INFand out-of-range float literals on PHP 8.5+ (backport) by @alies-dev in #13584Internal changes
Other changes
New Contributors
Full Changelog: https://github.com/vimeo/psalm/compare/7.3.0...7.3.1
Configuration
📅 Schedule: (in timezone Europe/Berlin)
* 0-5 * * 1)🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.
This PR has been generated by Mend Renovate CLI.
292edd0fc941de9a64aeTests of CI / php (dev-master): passed
266 passed, 0 failed, 0 skipped (266 tests, 11.5 s)
Of
3c1eecb682, the run, updated by every run.Tests of CI / php (dev-stable32): passed
266 passed, 0 failed, 0 skipped (266 tests, 11.1 s)
Of
3c1eecb682, the run, updated by every run.Tests of CI / php (dev-stable33): passed
266 passed, 0 failed, 0 skipped (266 tests, 11.0 s)
Of
3c1eecb682, the run, updated by every run.Tests of CI / php (dev-stable34): passed
266 passed, 0 failed, 0 skipped (266 tests, 11.2 s)
Of
3c1eecb682, the run, updated by every run.Tests of CI / php (dev-stable35): passed
266 passed, 0 failed, 0 skipped (266 tests, 10.9 s)
Of
3c1eecb682, the run, updated by every run.41de9a64ae3c1eecb6823c1eecb6826bb68adc01View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.