Changelog History
Page 3
-
v3.0.0-RC2 Changes
May 02, 2020๐ The Phan 3.x releases support analysis of php 7.0-7.4, and can be executed with php 7.2+.
๐ Use the older Phan 2.x releases if you need to continue to execute Phan with php 7.1.
๐ Use the older Phan 1.x releases if you need to execute Phan with php 7.0.๐ Changes
- ๐ Fix the published commit for the GitHub release (use the
v3
branch instead of themaster
branch)
Backwards incompatible changes:
- ๐ Drop PHP 7.1 support. PHP 7.1 reached its end of life for security support in December 2019.
๐ Many of Phan's dependencies no longer publish releases supporting php 7.1,
which will likely become a problem running Phan with future php 8.x versions
๐ (e.g. in the published phar releases). - โฌ๏ธ Drop PluginV2 support (which was deprecated in Phan 2) in favor of PluginV3.
- โ Remove deprecated classes and helper methods.
- ๐ Fix the published commit for the GitHub release (use the
-
v3.0.0-RC1 Changes
May 02, 2020๐ USE 3.0.0-RC2 INSTEAD (the git tag incorrectly uses the 2.x branch instead of 3.x)
๐ The Phan 3.x releases support analysis of php 7.0-7.4, and can be executed with php 7.2+.
๐ Use the older Phan 2.x releases if you need to continue to execute Phan with php 7.1.
๐ Use the older Phan 1.x releases if you need to execute Phan with php 7.0.Backwards incompatible changes:
- ๐ Drop PHP 7.1 support. PHP 7.1 reached its end of life for security support in December 2019.
๐ Many of Phan's dependencies no longer publish releases supporting php 7.1,
which will likely become a problem running Phan with future php 8.x versions
๐ (e.g. in the published phar releases). - โฌ๏ธ Drop PluginV2 support (which was deprecated in Phan 2) in favor of PluginV3.
- โ Remove deprecated classes and helper methods.
- ๐ Drop PHP 7.1 support. PHP 7.1 reached its end of life for security support in December 2019.
-
v2.7.3 Changes
July 02, 2020Phan 3 is out (requires PHP 7.2+ to run),
๐ and that release line will contain all of Phan's new features, bug fixes, and crash fixes.๐ง Maintenance:
- ๐ Mention that Phan 3 has been released in
--help
,--version
, and crash reports. (#3903)
The environment variablePHAN_SUPPRESS_PHP_UPGRADE_NOTICE=1
can be set to disable this notice. - ๐ Warn if attempting to execute Phan 2.x with PHP 8.0-dev or newer (A future release of Phan 3 will fully support 8.0)
- Recommend using Phan 3 when
--target-php-version
ortarget_php_version
is 7.2 or newer. - ๐ Upgrade package versions in composer.lock (affects Phar releases)
๐ Bug fixes:
- ๐ Fix handling of windows path separators in
phan_client
- ๐ Fix a crash when emitting
PhanCompatibleAnyReturnTypePHP56
orPhanCompatibleScalarTypePHP56
for methods with no parameters.
- ๐ Mention that Phan 3 has been released in
-
v2.7.2 Changes
May 02, 2020๐ New features(CLI, Config):
โ Add a
--native-syntax-check=/path/to/php
option to enableInvokePHPNativeSyntaxCheckPlugin
and add that php binary to thephp_native_syntax_check_binaries
array ofplugin_config
๐ง (treated here as initially being the empty array if not configured).This CLI flag can be repeated to run PHP's native syntax checks with multiple php binaries.
๐ New features(Analysis):
Emit
PhanTypeInvalidThrowStatementNonThrowable
when throwing expressions that can't cast to\Throwable
. (#3853)Include the relevant expression in more issue messages for type errors. (#3844)
0๏ธโฃ Emit
PhanNoopSwitchCases
when a switch statement contains only the default case.Warn about unreferenced private methods of the same name as methods in ancestor classes, in dead code detection.
Warn about useless loops. Phan considers loops useless when the following conditions hold:
Variables defined within the loop aren't used outside of the loop
(requiresunused_variable_detection
to be enabled whether or not there are actually variables)It's likely that the statements within the loop have no side effects
(this is only inferred for a subset of expressions in code)(Enabling the plugin
UseReturnValuePlugin
(and optionally'plugin_config' => ['infer_pure_methods' = true]
) helps detect if function calls are useless)The code is in a functionlike scope.
๐ New issue types:
PhanSideEffectFreeForeachBody
,PhanSideEffectFreeForBody
,PhanSideEffectFreeWhileBody
,PhanSideEffectFreeDoWhileBody
Infer that previous conditions are negated when analyzing the cases of a switch statement (#3866)
๐ Support using
throw
as an expression, for PHP 8.0 (#3849)
(e.g.is_string($arg) || throw new InvalidArgumentException()
)
EmitPhanCompatibleThrowException
whenthrow
is used as an expression instead of a statement.๐ Plugins
- ๐ Emit
PhanPluginDuplicateCatchStatementBody
inDuplicateExpressionPlugin
when a catch statement has the same body and variable name as an adjacent catch statement.
๐ (This should be suppressed in projects that support php 7.0 or older) - โ Add
PHP53CompatibilityPlugin
as a demo plugin to catch common incompatibilities with PHP 5.3. (#915)
๐ New issue types:PhanPluginCompatibilityArgumentUnpacking
,PhanPluginCompatibilityArgumentUnpacking
,PhanPluginCompatibilityArgumentUnpacking
- โ Add
DuplicateConstantPlugin
to warn about duplicate constant names (define('X', value)
orconst X = value
) in the same statement list.
This is only recommended in projects with files with too many global constants to track manually.
๐ Bug Fixes:
- ๐ Fix a bug causing FQSEN names or namespaces to be converted to lowercase even if they were never lowercase in the codebase being analyzed (#3583)
Miscellaneous:
- 0๏ธโฃ Replace
PhanTypeInvalidPropertyDefaultReal
withTypeMismatchPropertyDefault
(emitted instead ofTypeMismatchProperty
)
0๏ธโฃ andTypeMismatchPropertyDefaultReal
(#3068) - ๐ Speed up
ASTHasher
for floats and integers (affects code such asDuplicateExpressionPlugin
) - ๐ Call
uopz_allow_exit(true)
if uopz is enabled when initializing Phan. (#3880)
โ Running Phan withuopz
is recommended against (unless debugging Phan itself), becauseuopz
causes unpredictable behavior.
๐ Use stubs or internal stubs instead.
- ๐ Emit
-
v2.7.1 Changes
April 12, 2020๐ New features(CLI, Configs):
- ๐ Improve the output of
tool/make_stubs
. Use better defaults thannull
.
0๏ธโฃ Renderunknown
for unknown defaults intool/make_stubs
and Phan's issue messages.
0๏ธโฃ (default
is a reserved keyword used in switch statements)
๐ Bug Fixes:
- Work around unintentionally using
symfony/polyfill-72
forspl_object_id
instead of Phan's polyfill.
The version used caused issues on 32-bit php 7.1 installations, and a slight slowdown in php 7.1.
๐ Plugins:
- ๐ PHP 8.0-dev compatibility fixes for
InvokePHPNativeSyntaxCheckPlugin
on Windows. - ๐ Infer that some new functions in PHP 8.0-dev should be used in
UseReturnValuePlugin
- Emit the line and expression of the duplicated array key or switch case (#3837)
- ๐ Improve the output of
-
v2.7.0 Changes
April 01, 2020๐ New features(CLI, Configs):
- Sort output of
--dump-ctags=basic
by element type before sorting by file name (#3811)
(e.g. make class and global function declarations the first tag type for a tag name) - 0๏ธโฃ Colorize the output of
phan_client
by default for the default and text output modes. (#3808)
โ Addphan --no-color
option to disable colors. - Warn about invalid CLI flags in
phan_client
(#3776) - ๐ Support representing more AST node types in issue messages. (#3783)
- ๐ Make some issue messages easier to read (#3745, #3636)
- ๐ Allow using
--minimum-severity=critical
instead of--minimum-severity=10
(#3715) - 0๏ธโฃ Use better placeholders for parameter default types than
null
in issue messages and hover text (#3736) - ๐ Release
phantasm
, a prototype tool for assembling information about a codebase and aggressively optimizing it.
Currently, the only feature is replacing class constants with their values, when safe to do so.
โก๏ธ More features (e.g. inlining methods, aggressively optimizing out getters/setters, etc.) are planned for the future.
๐ Seetool/phantasm --help
for usage.
๐ New features(Analysis):
- ๐ Improve analysis of php 7.4 typed properties.
๐ Support extracting their real union types from Reflection information.
0๏ธโฃ Infer the existence of properties that are not inReflectionClass->getPropertyDefaults()
0๏ธโฃ due to being uninitialized by default. - Emit
PhanAbstractStaticMethodCall*
when calling an abstract static method statically. (#3799) - Emit
PhanUndeclaredClassReference
instead ofPhanUndeclaredClassConstant
forMissingClass::class
.
Language Server/Daemon mode:
- ๐ Catch exception seen when printing debug info about not being able to parse a file.
- Warn when Phan's language server dependencies were installed for php 7.2+
but the language server gets run in php 7.1. (phpdocumentor/reflection-docblock 5.0 requires php 7.2) - Immediately return cached hover text when the client repeats an identical hover request. (#3252)
Miscellaneous:
- ๐ PHP 8.0-dev compatibility fixes, analysis for some new functions of PHP 8.0-dev.
- โ Add
symfony/polyfill-php72
dependency so that symfony 5 will work better in php 7.1.
๐ The next Phan major release will drop support for php 7.1.
- Sort output of
-
v2.6.1 Changes
March 13, 2020๐ New features(CLI, Configs):
- โ Add a
--dump-ctags=basic
flag to dump atags
file in the project root directory. (https://linux.die.net/man/1/ctags)
This is different fromtool/make_ctags_for_phan_project
---dump-ctags=basic
has no external dependencies.
๐ New features(Analysis):
- Infer that the real type set of the key in
foreach ($arrayVar as $key => ...)
is definitely anint|string
in places where Phan previously inferred the empty union type, improving redundant condition detection. (#3789)
๐ Bug fixes:
- ๐ Fix a crash in
phan --dead-code-detection
when a trait defines a real method and phpdoc@method
of the same name (#3796)
Miscellaneous:
- Also allow
netresearch/jsonmapper@^2.0
as a dependency when enforcing the minimum allowed version (#3801)
- โ Add a
-
v2.6.0 Changes
March 07, 2020๐ New features(CLI, Configs):
๐ Show empty union types as
(empty union type)
in issue messages instead of as an empty string.โ Add a new CLI option
--analyze-twice
to run the analysis phase twice (#3743)Phan infers additional type information for properties, return types, etc. while analyzing,
and this will help it detect more potential errors.
(on the first run, it would analyze files before some of those types were inferred)Add a CLI option
--analyze-all-files
to analyze all files, ignoringexclude_analysis_file_list
.
๐ This is potentially useful if third party dependencies are missing type information (also see--analyze-twice
).โ Add
--dump-analyzed-file-list
to dump all files Phan would analyze to stdout.Add
allow_overriding_vague_return_types
to allow Phan to add inferred return types to functions/closures/methods declared with@return mixed
or@return object
.
0๏ธโฃ This is disabled by default.When this is enabled, it can be disabled for individual methods by adding
@phan-hardcode-return-type
to the comment of the method.
(if the method has any type declarations such as@return mixed
)Previously, Phan would only add inferred return types if there was no return type declaration.
๐ (also see--analyze-twice
)Also emit the code fragment for the argument in question in the
PhanTypeMismatchArgument
family of issue messages (#3779)Render a few more AST node kinds in code fragments in issue messages.
๐ New features(Analysis):
๐ Support parsing php 8.0 union types (and the static return type) in the polyfill. (#3419, #3634)
๐ Emit
PhanCompatibleUnionType
andPhanCompatibleStaticType
when the target php version is less than 8.0 and union types or static return types are seen. (#3419, #3634)โ Be more consistent about warning about issues in values of class constants, global constants, and property defaults.
Infer key and element types from
iterator_to_array()
Infer that modification of or reading from static properties all use the same property declaration. (#3760)
Previously, Phan would track the static property's type separately for each subclass.
(static properties from traits become different instances, in each class using the trait)๐ Make assignments to properties of the declaring class affect type inference for those properties when accessed on subclasses (#3760)
Note that Phan is only guaranteed to analyze files once, so if type information is missing,
๐ the only way to ensure it's available is to add it to phpdoc (UnknownElementTypePlugin
can help) or use--analyze-twice
.๐ Make internal checks if generic array types are strict subtypes of other types more accurate.
(e.g.object[]
is not a strict subtype ofstdClass[]
, butstdClass[]
is a strict subtype ofobject[]
)๐ Plugins:
- โ Add
UnknownClassElementAccessPlugin
to warn about cases where Phan can't infer which class an instance method is being called on.
๐ (To work correctly, this plugin requires that Phan use a single analysis process) - โ Add
MoreSpecificElementTypePlugin
to warn about functions/methods where the phpdoc/actual return type is vaguer than the types that are actually returned by a method. (#3751)
๐ง This is a work in progress, and has a lot of false positives.
๐ (To work correctly, this plugin requires that Phan use a single analysis process) - ๐ Fix crash in
PrintfCheckerPlugin
when analyzing code wherefprintf()
was passed an array instead of a format string. - Emit
PhanTypeMissingReturnReal
instead ofPhanTypeMissingReturn
when there is a real return type signature. (#3716) - ๐ Fix bug running
InvokePHPNativeSyntaxCheckPlugin
on Windows when PHP binary is in a path containing spaces. (#3766)
๐ Bug fixes:
- ๐ Fix bug causing Phan to fail to properly recursively analyze parameters of inherited methods (#3740)
(i.e. when the methods are called on the subclass) - ๐ Fix ambiguity in the way
Closure():T[]
andcallable():T[]
are rendered in error messages. (#3731)
Either render it as(Closure():T)[]
orClosure():(T[])
- Don't include both
.
andvendor/x/y/
when initializing Phan configs with settings such as--init --init-analyze-dir=.
(#3699) - Be more consistent about resolving
static
in generators and template types. - Infer the iterable value type for
Generator<V>
. It was previously only inferred when there were 2 or more template args in phpdoc. - Don't let less specific type signatures such as
@param object $x
override the real type signature ofMyClass $x
(#3749) - ๐ Support PHP 7.4's
??=
null coalescing assignment operator in the polyfill. - ๐ Fix crash analyzing invalid nodes such as
2 = $x
inRedundantAssignmentPlugin
. - ๐ Fix crash inferring type of
isset ? 2 : 3
with--use-fallback-parser
(#3767) - ๐ Fix false positive unreferenced method warnings for methods from traits
when the methods were referenced in base classes or interfaces of classes using those traits.
Language Server/Daemon mode:
- โ Add
-
v2.5.0 Changes
February 20, 2020๐ New Features(CLI):
- ๐ Support using
directory_suppressions
in Phan baseline files in--load-baseline
. (#3698) - ๐ Improve error message for warnings about Phan being unable to read files in the analyzed directory.
๐ New Features(Analysis):
๐ Instead of failing to parse intersection types in phpdoc entirely, parse them as if they were union types. (#1629)
The annotations@phan-param
,@phan-return
,@phan-var
, etc. can be used to override the regular phpdoc in the various cases where this behavior causes problems.Future Phan releases will likely about unsupported phpdoc (e.g.
int&string
) and have actual support for intersection types.๐ Emit
PhanUndeclaredConstantOfClass
(severity critical) for undeclared class constants instead ofPhanUndeclaredConstant
(severity normal)
This should not be confused withPhanUndeclaredClassConstant
, which already exists and refers to accessing class constants of classes that don't exist.Emit the expression that's an invalid object with issue types such as
PhanTypeExpectedObject*
,PhanTypeInvalidInstanceof
(#3717)Emit
PhanCompatibleScalarTypePHP56
andPhanCompatibleAnyReturnTypePHP56
for function signatures whentarget_php_version
is'5.6'
(#915)
(This also requires thatbackward_compatibility_checks
be enabled.)โ Use more accurate line numbers for warnings about function parameters.
When
assume_real_types_for_internal_functions
is on and a function has a non-empty return type in Reflection,
๐ make Phan's known real type signatures override the real reflection return type information (useful when Phan inferslist<string>
and Reflection saysarray
).
Phan previously used the type from Reflection.Normalize phpdoc parameter and return types when there is a corresponding real type in the signature. (#3725)
(e.g. convertbool|false|null
to?bool
)๐ Plugins:
- โ Add
SubscribeEmitIssueCapability
to detect or suppress issues immediately before they are emitted. (#3719)
๐ Bug fixes:
- Don't include issues that weren't emitted in the file generated by
--save-baseline
(#3719) - ๐ Fix incorrect file location for other definition in
PhanRedefinedClassReference
under some circumstances. - ๐ Fix incorrect issue name:
PhanCompatibleNullableTypePHP71
should be namedPhanCompatibleObjectTypePHP71
- ๐ Fix false positive
PhanPartialTypeMismatchProperty
when a php 7.4 typed property has a default expression value (#3725)
- ๐ Support using
-
v2.4.9 Changes
February 13, 2020๐ New Features(Analysis):
Infer that
class_exists
implies the first argument is a class-string,
and thatmethod_exists
implies the first argument is a class-string or an object. (#2804, #3058)Note that Phan still does not infer that the class or method actually exists.
Emit
PhanRedefineClass
on all occurrences of a duplicate class, not just the ones after the first occurrence of the class. (#511)Emit
PhanRedefineFunction
on all occurrences of a duplicate function/method, not just the ones after the first.๐ Emit
PhanRedefinedClassReference
for many types of uses of user-defined classes that Phan has parsed multiple definitions of.
Phan will not warn about internal classes, because the duplicate definition is probably a polyfill.
(e.g.new DuplicateClass()
,DuplicateClass::someMethod()
)๐ Bug fixes:
- Fix false positive
PhanParamSuspiciousOrder
forpreg_replace_callback
(#3680) - ๐ Fix false positive
PhanUnanalyzableInheritance
for renamed methods from traits. (#3695) - ๐ Fix false positive
PhanUndeclaredConstant
previously seen for inherited class constants in some parse orders. (#3706) - ๐ Fix uncaught
TypeError
convertingiterable<T>
to nullable (#3709)
- Fix false positive