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)
-
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:
- Replace
PhanTypeInvalidPropertyDefaultReal
withTypeMismatchPropertyDefault
(emitted instead ofTypeMismatchProperty
)
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.