New Features(Analysis):
-
Fix false positive PhanPossiblyUndeclaredVariable warning when a
try
block unconditionally returns/throws/exits (#4419) -
Fix false positive warnings when analyzing enums, infer that automatically generated methods of enums exist. (#4313)
-
Properly resolve template type when
getIterator
returns anIterator
that includes a template. (#4556) -
Fix false positives such as
PhanTypeMismatchArgumentNullable
analyzing recursive call with parameter set to literal, without real type information. (#4550)
(e.g.function ($retry = true) { if ($retry) {/*...*/} some_call_using_retry($retry); }
) -
Properly detect
PhanUnusedVariable
in try-catch where catch always rethrows. (#4567) -
Make read-only/write-only property detection more accurate for assignment operations (e.g.
+=
,??=
) and increment/decrement operations. (#4570) -
Improve estimates of array sizes when analyzing calls that unpack values, based on the inferred real type set. (#4577)
-
Infer that variadic parameters can have string keys (as of php 8.0) (#4579)
-
Emit
PhanParamTooFewUnpack
andPhanParamTooFewInternalUnpack
to indicate when argument unpacking may provide too few arguments to the called function. (#4577) -
Support the non-standard
@no-named-arguments
PHPDoc comment on function-likes. (#4580, #4152)
Treat variadic parameters as list types when this annotation is used,
warn about unpacking string arguments or explicitly passing named arguments to functions using this declaration. -
Warn about argument unpacking that may pass strings to internal functions (e.g.
var_dump(...['a' => 'unsupported'])
) (#4579)
New issue types:PhanSuspiciousNamedArgumentVariadicInternalUnpack
-
Support
@phan-type AliasName=UnionType
annotation in inline strings or element comments (#4562)These aliases will apply to remaining statements in the current
top-level namespace blocks, similar to use statements, but can also be defined
in methods and apply to subsequent methods.This can be of use in avoiding repetition of phpdoc for long type definitions.
// Alternate inline string version to work around php-ast limitations '@phan-type UserData = array{name: string, id: int, createdAt: DateTime}'; /** * @type-alias UserData = array{name: string, id: int, createdAt: DateTime} * (applies to phpdoc in this and all subsequent AST nodes in the namespace block) */ class ExampleElementWithPHPDoc { /** * @param UserData[] $users * @return list<UserData> */ public function filterUsers(array $values): array { /* ... */ } } // The UserData alias is still defined and can be used in other statements namespace XYZ; // The UserData alias is no longer defined in the new namespace block.
-
When analyzing calls that modify variables as pass by reference, merge old types with existing types
to account for possibility of branches or early returns (#4602)
Plugins:
- Warn about non-empty try statements that are unlikely to throw in
EmptyStatementListPlugin
(#4555) - Warn in
AlwaysReturnPlugin
about functions/methods with no return type that have at least one return statement with an expression, but may fall through to the end of the function body without an explicit return (#4587)
Bug fixes:
- Fix off-by-one error when inferring from comparison conditions such as
count($arr) > 0
andcount($arr) >= 1
that the array is non-empty. (#4551) - Fix checking file path suppressed by baseline (with
/
) on windows (#4149) - Fix crash when inferring type of array access for scalar other than int/string (e.g.
$arr[true]
) (#4573) - Properly read
--processes N
CLI flag before checking if phan should restart withoutgrpc
(#4608)
Maintenance:
- Account for a few PHP 8.0 signature changes for PDOStatement::fetchAll and Phar methods. (#4569)