This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^3.1
->^5.0
Release Notes
phan/phan (phan/phan)
v5.4.5
: supporting PHP 7.0-8.2 syntaxCompare Source
New features(Analysis):
PhanDeprecatedImplicitNullableParam
for uses of implicitly nullable parameters (int $x = null
instead of?int $x = null
). These can be fixed automatically via the accompanying IssueFixer. #4875New features(CLI, Configs):
Add
override_return_types
to add types to all return types. Normally, Phan only adds inferred returned types when there is no@return
typeor real return type signature. This setting can be disabled on individual methods by adding
@phan-hardcode-return-type
to the doc comment.Disabled by default. This is more useful with
--analyze-twice
and in conjunction withPhoundPlugin
todetect more callsite possibilities. See the PR description where
this setting was added for more details.
(Default:
false
)Along with this change, we are analyzing the return types of traits a bit more aggressively now. #4874
Bug fixes:
Maintenance:
v5.4.4
: supporting PHP 7.0-8.2 syntaxCompare Source
New features:
Miscellaneous:
v5.4.3
: supporting PHP 7.0-8.2 syntaxCompare Source
New Features(Analysis):
@throws
types from parent methods ifenable_phpdoc_types
is true (which it is by default). (#4757)Miscellaneous:
Bug fixes:
PhanTypeMismatchUnpackKeyArraySpread
whenminimum_target_php_version
is'8.1'
or newer. (#4788)ini_set()
instead ofassert_options()
when Phan's assertion options match PHP's assert ini setting defaults to keep those values and avoid deprecation warnings in php 8.3+.\x00
(APCu
,immutable_cache
)This release fixes errors and deprecations seen running Phan with PHP 8.3, but it does not support analyzing most new syntax/features/changes deprecations of PHP 8.3 itself.
v5.4.2
: supporting PHP 7.0-8.2 syntaxCompare Source
Miscellaneous:
EmptyStatementListPlugin
issue messages.exif_read_data()
(#4759)allow_missing_properties
setting aware ofAllowDynamicProperties
attribute for PHP 8.2Maintenance:
This release of php-ast makes the parsing of
AST_ARROW_FUNC
in php 8.2 match older php versions.readonly
classes in the polyfill/fallback parser.__halt_compiler()
in the polyfill/fallback parser.v5.4.1
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features(Analysis):
A|(B&C)
(https://wiki.php.net/rfc/dnf_types). (#4699)Emit
PhanCompatibleTraitConstant
when using constants on traits with aminimum_target_php_version
below'8.2'
Emit
PhanAccessClassConstantOfTraitDirectly
when directly referencing the class constant on the trait declaration.PhanTypeModifyImmutableObjectProperty
for PHP 8.1readonly
properties when modified anywhere outside of thedeclaring class's scope. (#4710)
Miscellaneous:
array_filter
$callback
to be null (#4715)v5.4.0
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features(CLI, Configs):
tool/analyze_phpt
to analyze phpt files. See https://www.phpinternalsbook.com/tests/phpt_file_structure.htmlNew Features(Analysis):
true
type (https://wiki.php.net/rfc/true-type).Emit
PhanCompatTrueType
whentrue
is used whenminimum_target_php_version
is less than 8.2.PhanCompatStandaloneType
instead ofPhanInvalidNode
for uses of null/false as real standalone types to support php 8.2 https://wiki.php.net/rfc/null-false-standalone-types(Not emitted when
minimum_target_php_version
is 8.2 or higher)Bug fixes:
ast\Node
when running Phan in php 5.2.0 with the polyfill instead of the native php-ast version.(This fix is only enabled in php 7.3+ when using pcntl, the pcntl fallback already re-enabled garbage collection. php 7.3 improved the garbage collection efficiency for large collections of objects.)
PhanGenericConstructorTypes
warning to the class inheriting a constructor if needed (#4675)"${}"
string interpolation (#4692)v5.3.2
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features(Analysis):
$var
inin_array($var, $array)
instead of just the type of the array elements (#4630)
phan --init
, allow inferring php 8.1 as the target php version in the generated config file. (#4655)Maintenance:
Bug fixes:
Fix AST download link for PHP 8.0+ for Windows (#4645)
Fix dead code detection for PHP 8.0 non-capturing catch statements. (#4633)
This should still analyze the catch body even if there is no caught exception variable.
Ignore phpdoc comment tags that don't start at the start of a line of the doc comment (
* @​sometag
) or aren't an inline tag (* something {@​sometag}
). (#4640)See https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/internal.html and https://docs.phpdoc.org/2.9/guides/docblocks.html
E.g.
* This is not @​abstract.
is no longer treated as an abstract method.v5.3.1
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features(Analysis):
PhanDeprecatedPartiallySupportedCallable
for functions that work withcall_user_func($expr)
but not$expr()
.The literal strings
'self'
,'parent'
, and'static'
in'self::methodName'
or['self', 'methodName']
in callables were deprecated in PHP 8.2.PhanDeprecatedPartiallySupportedCallableAlternateScope
for uses of callables such as[new SubClass(), 'Base::method']
specifying an alternate scope.Plugins:
PhanPluginUnknownClosureParamType
andPhanPluginUnknownFunctionParamType
.Bug fixes:
#[AllowDynamicProperties]
.v5.3.0
: supporting PHP 7.0-8.1 syntaxCompare Source
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.
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:
EmptyStatementListPlugin
(#4555)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:
count($arr) > 0
andcount($arr) >= 1
that the array is non-empty. (#4551)/
) on windows (#4149)$arr[true]
) (#4573)--processes N
CLI flag before checking if phan should restart withoutgrpc
(#4608)Maintenance:
v5.2.1
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features:
E.g. support
if ($x === []) {...} else {...}
,if (count($x) > 0) {...} else {...}
, etc.PhanTypeNonVarPassByRef
to critical. It throws an Error in php 8.0+. (#3830)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:
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 as
fwrite(): write of 8196 bytes failed with errno=32 Broken pipe
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 issuesFix 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)Maintenance:
get_headers
(#3273)v5.2.0
: supporting PHP 7.0-8.1 syntaxCompare Source
Plugins
AddNeverReturnTypePlugin`` which will suggest adding a phpdoc return type of
@return never`. (#4468)Bug fixes:
numeric-string
in all phpdocPhanTypeMismatchPropertyDefaultReal
warning for literal integer andfloat
typed property. (#4507)PhanImpossibleTypeComparison
about string subtypes not casting to other string subtypes (#4514)Maintenance:
BlockExitStatusChecker
to indicate that a function will exit or infinitely loop (STATUS_NORETURN
) (#4468)v5.1.0
: supporting PHP 7.0-8.1 syntaxCompare Source
New Features (Analysis):
Documentation:
--target-php-version
and--minimum-target-php-version
v5.0.0
: supporting PHP 7.0-8.1 syntaxCompare Source
If you are migrating from Phan 4, it may be useful to set up or update a Phan baseline file to catch issues such as nullable type mismatches.
https://github.com/phan/phan/wiki/Tutorial-for-Analyzing-a-Large-Sloppy-Code-Base has other advice on setting up suppressions.
For example, Phan is now more consistently warning about nullable arguments (i.e. both
\X|null
and?\X
) in a few cases where it may have not warned about passing\X|null
to a function that expects a non-null type.If you are using plugins for Phan 4 that are not part of Phan itself, they may have issues in Phan 5 due
to additional required parameters being added to many of Phan's methods.
See the changelog for other changes in the previous alpha releases: https://github.com/phan/phan/blob/5.0.0/NEWS.md
New Features (Analysis):
Warn about implicitly nullable parameter intersection types (
function(A&B $paramName = null)
) being a compile error.New issue type:
PhanTypeMismatchDefaultIntersection
Emit
PhanTypeMismatchArgumentSuperType
instead ofPhanTypeMismatchArgument
when passing in an object supertype (e.g. ancestor class) of an object instead of a subtype.Emit
PhanTypeMismatchReturnSuperType
instead ofPhanTypeMismatchReturn
when returning an object supertype (e.g. ancestor class) of an object instead of a subtype.Phan 5 starts warning about ancestor classes being incompatible argument or return types in cases where it previously allowed it. (#4413)
v4.1.0
: supporting PHP 7.0-8.0 syntaxCompare Source
Maintenance:
--help
,--version
, and crash reports (#4487)The environment variable
PHAN_SUPPRESS_PHP_UPGRADE_NOTICE=1
can be set to disable this notice.(...)
and avoid crashing when parsing intersection types.Note that Phan 5 must be used instead to actually support intersection types; intersection types are not part of Phan 4's type system.
v4.0.7
: supporting PHP 7.0-8.0 syntaxCompare Source
The Phan 5 release line (currently in alpha) will support PHP 8.1 syntax and new features such as intersection types
Language Server/Daemon mode:
Maintenance:
Bug fixes:
Don't emit
PhanCompatibleNonCapturingCatch
whenminimum_target_php_version
is'8.0'
or newer. (#4433)Stop ignoring
@return null
and@param null $paramName
in phpdoc. (#4453)Stop special casing
@param null
now that Phan allows many other literal types in param types.v4.0.6
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features (Analysis):
Partially support php 8.1 enums (#4313)
(infer the real type is the class type, that they cannot be instantiated, that enum values cannot be reused, and that class constants will exist for enum cases)
New issue types:
PhanReusedEnumCaseValue
,PhanTypeInstantiateEnum
,PhanTypeInvalidEnumCaseType
,PhanSyntaxInconsistentEnum
,PhanInstanceMethodWithNoEnumCases
,PhanInstanceMethodWithNoEnumCases
,PhanEnumCannotHaveProperties
,PhanUnreferencedEnumCase
,PhanEnumForbiddenMagicMethod
.Support php 7.4 covariant return types and contravariant parameter types when the configured or inferred
minimum_target_php_version
is'7.4'
or newer (#3795)Add initial support for the php 8.1
never
type (in real return types and phpdoc). (#4380)Also add support for the phpdoc aliases
no-return
,never-return
, andnever-returns
Support casting
iterable<K, V>
toTraversable<K, V>
withis_object
or!is_array
checksDetect more types of expressions that never return when inferring types (e.g. when analyzing
?:
,??
operators)Use php 8.1's tentative return types from reflection (
hasTentativeReturnType
,getTentativeReturnType
) to assume real return types of internal functions/methods (#4400)This can be disabled by setting
use_tentative_return_type
tofalse
(e.g. when using subclasses of internal classes that return incompatible types).Warn about modifying properties of classes that are immutable at runtime (enums, internal classes such as
\Closure
and\WeakRef
, etc.) (#4313)New issue type:
PhanTypeModifyImmutableObjectProperty
Dead code detection:
Infer that functions with a return type of
never
(or phpdoc aliases such asno-return
) are unreachable when performing control flow analysis.This can be disabled by setting
dead_code_detection_treat_never_type_as_unreachable
to falseNote that control flow is only affected when
UseReturnValuePlugin
is enabled.Plugins:
UseReturnValuePlugin
, also start warning about when using the result of an expression that evaluates tonever
New issue types:
PhanUseReturnValueOfNever
Bug fixes:
As part of the work on php 7.4 contravariant parameter types,
don't automatically inherit inferred parameter types from ancestor classlikes when (1) there is no
@param
tag with a type for the parameter on the overriding method and (2) the ancestor parameter types are a subtype of the real parameter types unless@inheritDoc
is used.array<string,mixed>
that is a specialization of an array type.If you want to indicate that the overriding method can be any array type, add
@param array $paramName
.Change composer.json dependency on
composer/xdebug-handler
from^2.0
to^1.1|2.0
to avoid conflicting with other libraries or applications that depend on xdebug-handler 1.x (#4382)Support parsing multiple declare directives in the polyfill/fallback parser (#4160)
v4.0.5
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features (Analysis):
non-null-mixed
andnull
(#4388, #4391)PhanCompatibleSerializeInterfaceDeprecated
when a class implements Serializable without also implementing the__serialize
and__unserialize
methods as well. (#4387)PHP 8.1 deprecates the
Serializable
interface when__serialize
and__unserialize
aren't also implemented to be used instead ofserialize
/unserialize
.Maintenance:
__serialize
/__unserialize
in Phan itself in places that useSerializable
.Phan\Language\Type
to account for changes in static variable inheritance in php 8.1. (#4379)Bug fixes:
?T
to be used in parameter/property types with@template T
(#4388)v4.0.4
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features (CLI, Config):
--doc-comment
flag ontool/make_stubs
to emit the doc comments Phanis using for internal elements along with the stubs.
(these are the doc comments Phan would use for hover text in the language server)
target_php_version
andminimum_target_php_version
to be 8.1 or newer.New Features (Analysis):
Don't emit warnings about array unpacking with string keys when
minimum_target_php_version
is '8.1' or newer.array_is_list(array $array): bool
conditional and its negation. (#4348)Bug fixes:
Maintenance:
Plugins:
ConfigPluginSet
. This is useful for unit testing stateless plugins which declare the plugin class in the same file returning the plugin instance. (#4352)v4.0.3
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features:
getIterator
returning an ordinaryIterator<X>
(previously only inferred types for subclasses of Iterator)Bug fixes:
[...$x]
in an issue message (#4351)if ($x)
converts non-null-mixed
tonon-empty-mixed
self::CONST_NAME
from inside of a subclass of the constant's declaring class (#4360)allow_method_param_type_widening
fromminimum_target_php_version
to avoid false positivePhanParamSignatureRealMismatchHasNoParamType
.v4.0.2
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features:
PhanUndeclaredThis
inside of static methods/closures (#4336)Language Server/Daemon mode:
::
and->
at the end of a line on files using Windows line endings(\r\n
) instead of Unix newlines(\n
) on any OS (#4345)Previously, those were not completed.
Bug fixes:
PhanParamSignatureMismatch
for variadic overriding a function usingfunc_get_args()
(#4340)to
function(paramtypes):returntype
(#4343)v4.0.1
: supporting PHP 7.0-8.0 syntaxCompare Source
New Features:
PhanCompatibleAssertDeclaration
when declaring a function calledassert
. (#4333)Bug fixes:
PhanInvalidConstantExpression
for named arguments in attributes (#4334)Merge changes from Phan 3.2.10
v4.0.0
: supporting PHP 7.0-8.0 syntaxCompare Source
The Phan v4 release line has the following changes from Phan 3:
A few third party plugins may be affected by the increase of the AST version.
#[...]
attributes are used properly when run with PHP 8.0+Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.