Aug 18 2019, Phan 2.2.11
New features (Analysis):
@phan-real-returnannotation for functions/methods/closure (#3099), to make Phan act as if that method has the specified union type when analyzing callers for redundant conditions, etc. (if there was no real type). This can be used for multiple types, e.g.
PhanTypePossiblyInvalidCloneNotObjectfor cloning possible non-objects when strict param checking is enabled.
new $expr()has a real type of object in all cases, not just common ones.
~(expr)and warn about redundant conditions. This does not attempt to account for custom behavior for objects provided by PECL extensions.
PhanSyntaxErrorfor unexpected tokens in more cases.
empty($x)implies that the value of $x is null, an empty scalar, or the empty array.
if (empty($x['first']['second']))- Do not infer any types for the offset 'first' if there weren't any already. (#3112)
A || B.
self, and internal functions building or processing arrays.
PhanTypeNonVarReturnByRefwhen an invalid expression is returned by a function declared to return a reference.
/** @phan-pure */. This is automatically inherited by overriding methods. Also see
'plugin_config' => ['infer_pure_methods' => true].
UseReturnValuePlugin, support inferring whether closures, functions, and methods are pure when
'plugin_config' => ['infer_pure_methods' => true]is enabled. (they're expected to not have side effects and should have their results used)
This is a best-effort heuristic. This is done only for the functions and methods that are not excluded from analysis, and it isn't done for methods that override or are overridden by other methods.
Note that functions such as
fopen() are not pure due to side effects.
UseReturnValuePlugin also warns about those because their results should be used.
Automatic inference of function purity is done recursively.
EmptyMethodAndFunctionPlugin to warn about functions/methods/closures with empty statement lists. (#3110)
This does not warn about functions or methods that are deprecated, overrides, or overridden.
+ Fix false positive in InvalidVariableIssetPlugin for expressions such as
plugins/vim/syntax/phan.vimThis makes it easier to tell if annotations were correctly typed.
'exclude_file_regex'while parsing. (#3088) That adds additional time and may cause unnecessary permissions errors.
Aug 12 2019, Phan 2.2.10
@param MyClass &$x @phan-ignore-reference, to make Phan ignore the impact of references on the passed in argument. (#3082) This can be used when the result should be treated exactly like the original type for static analysis.
voidto something expecting a non-null type. (#3085) This only occurs with some settings, e.g. when
null_casts_as_any_typeis true. (introduced in 2.2.9)
Aug 11 2019, Phan 2.2.9
New features (Analysis):
PhanTypeMismatchReturnwhen Phan infers that the real type of the returned expression is likely to cause a TypeError (accounting for
strict_typesin the file). (#403) See
internal/Issue-Types-Caught-by-Phan.mdfor details on when it is thrown.
PhanTypeMismatchArgumentwhen Phan infers that the real type of the argument is likely to cause a TypeError at runtime (#403)
is_array($this->array_prop)on typed properties. Their values will either be a value of the correct type, or unset. (Reading from unset properties will throw an Error at runtime)
PhanCompatibleTypedPropertyif the target php version is less than 7.4 but typed properties are used.
PhanTypeMismatchPropertyif the properties have real types that are incompatible with the inferred type of the assignment.
(float) $intbeing redundant - there are small differences in how ints and floats are treated by
$this->propin a scope the same way (for real, dynamic, and magic properties) Previously, Phan would not track the effects of some assignments to dynamic properties.
unset($this->prop)make Phan infer that the property is unset in the current scope (and treat it like null) (only affects
$this). (#3025) Emit
PhanPossiblyUnsetPropertyOfThisif the property is read from without setting it.
PhanTypeArraySuspiciousNullwhen array access is used with the null coalescing operator. (#3032)
PhanTypeInvalidDimOffsetwhen array access is used with the null coalescing operator. (#2123)
PhanUndeclaredTypePropertysuppressions on the property's doc comment, not the class. (#3047)
$this->prop = 'value';) for correctness and for the new type combination. (#3059)
voidshould be treated similarly to null (in addition to existing checks, it's redundant to compare them to null). Don't warn about
return null;in functions/methods with phpdoc-only
StrictComparisonPlugin, which warns about the following issue types:
array_search without specifying
EmptyStatementListPluginif a TODO/FIXME/"Deliberately empty" comment is seen around the empty statement list. (#3036) (This may miss some TODOs due to
php-astnot providing the end line numbers) The setting
'plugin_config' => ['empty_statement_list_ignore_todos' => true]can be used to make it unconditionally warn about empty statement lists.
PhanTypeMismatchPropertiesfor assignments to dynamic properties. (#3042)
$thisin the local scope. (#3038)
int(or a subtype) after the
TypeMismatchUnpack*for nullable key types of iterables if the union type didn't contain any int/mixed types. (fix logic error)
Jul 30 2019, Phan 2.2.8
New features (CLI):
tool/phoogleto better handle
object, and to include functions with nullable params in the results of searches for all functions. (#3014)
New features (Analysis):
PhanCompatibleImplodeOrderwhen the glue string is passed as the second instead of the first argument (#2089)
PhanCompatibleDimAlternativeSyntaxwhen using array and string array access syntax with curly braces when using the polyfill parser or php 7.4+. (#2989)
PhanCompatibleUnparenthesizedTernaryfor expressions such as
a ? b : c ? d : e. (#2989) (when using the polyfill parser or php 7.4+)
PhanConstructAccessSignatureMismatchwhen a constructor is less visible than the parent class's constructor and the target php version is 7.1 or older. (#1405)
ifstatements with negated conditions (those were previously skipped because they were simplified).
Jul 27 2019, Phan 2.2.7
New features (CLI, Configs):
PhanSyntaxError(inferred using the polyfill - these may be incorrect a small fraction of the time)
When the error is from the native
php-ast parser, this is a best guess at the column.
hide_issue_column can be used to remove the column from issue messages.
--absolute-path-issue-messages to emit absolute paths instead of relative paths for the file of an issue. (#1640)
Note that this does not affect files within the issue message.
+ Properly render the progress bar when Phan runs with multiple processes (#2928)
+ Add an HTML output mode to generate an unstyled HTML fragment.
Example CSS styles can be generated with
+ Add a
light color scheme for white backgrounds.
New features (Analysis):
@returnin addition to the real type.
instanceofchecks (e.g. to check for redundant conditions).
__toString()in php versions prior to php 7.4. (#2805)
PhanTypeArraySuspiciousNullfor code such as
$var->$propwhen $prop is a variable with a known string)
PhanUndeclaredVariableto distinguish those from undeclared variables within functions/methods. (#1652)
PhanCompatibleSyntaxNoticefor notices such as the deprecated
(real)cast in php 7.4, when the real parser is used (#3012)
Language Server/Daemon mode:
PhanSyntaxErroris emitted, make the start of the error range the column of the error instead of the start of the line.
EmptyStatementListPluginto warn about empty statement lists involving if/elseif statements, try statements, and loops.
@returnannotations followed by other annotation lines in
Foo::classas a reference to the class/interface/trait
(real)cast in php 7.4. (#3012)
Please login to add feedback.