New Features:
- Improve analysis of conditions detecting the empty/non-empty array. (#4523)
E.g. supportif ($x === []) {...} else {...}
,if (count($x) > 0) {...} else {...}
, etc. - Raise severity of
PhanTypeNonVarPassByRef
to critical. It throws an Error in php 8.0+. (#3830) - Infer from conditions such as
in_array($var, $array, true)
that $array is a non-empty array and that $var is of a type found in the elements of $array. (#2511)
Plugins:
- Emit a proper warning when
InvokePHPNativeSyntaxCheckPlugin
is passed a path to a php binary that is missing or invalid (or if the syntax check crashed). (#4116)
Previously, Phan would crash with an error such asfwrite(): write of 8196 bytes failed with errno=32 Broken pipe
- Fix false positive
PhanPluginMoreSpecificActualReturnType
for phpdoc array shape return type and returned generic array. (#4531)
Bug fixes:
-
Fix type inference logic that was looking for array specializations rather than array or any array subtype (#4512)
-
Fix false positive
PhanUnreferencedClosure
/PhanUnreferencedFunction
seen when a closure/function name was passed to a function such asuasort
that already had a plugin analyzing calls of the closure. (#4090, #4519) -
Fix false positive/negative
PhanTypeMissingReturn*
instances. (#4537)The check was wrong and should have been checking for a statement list that throws/exits.
Return statements can be omitted if a function unconditionally exits.Also, check for the real
never
return type when emitting issues -
Fix false positive
PhanPossiblyUndefinedGlobalVariable*
instance whenglobal $var
is used within a conditional. (#4539) -
Fix false positive
PhanPluginRedundantAssignmentInLoop
instance when a variable is modified in a catch statement with a break/continue. (#4542) -
Fix some incorrect line numbers in some plugin issues.
-
Fix crash seen when parsing intersection types containing union types such as
non-empty-array&array<'a'|'b'>
(#4544)