Changelog History
Page 4
-
v2.4.8 Changes
January 25, 2020๐ Bug fixes:
- ๐ Fix bug introduced in 2.4.7 where there were more false positives when
--no-progress-bar
was used. (#3677)
- ๐ Fix bug introduced in 2.4.7 where there were more false positives when
-
v2.4.7 Changes
January 23, 2020๐ New features(CLI, Configs):
- Add an environment variable
PHAN_NO_UTF8=1
to always avoid UTF-8 in progress bars.
๐ This may help with terminals or logs that have issues with UTF-8 output.
Error messages will continue to include UTF-8 when part of the error. - ๐ Allow
phan --init
to complete even if composer.json has no configuredautoload
directories,
๐ง as long as at least one directory or file was configured. - Add a setting
error_prone_truthy_condition_detection
that can be enabled to warn about error-prone truthiness/falsiness checks. New issue types:PhanSuspiciousTruthyCondition
(e.g. forif ($x)
where$x
isobject|int
)PhanSuspiciousTruthyString
(e.g. for?string
-'0'
is also falsey in PHP)
- โ Limit calculation of max memory usage to the running worker processes with
--processes N
(#3606) - Omit options that should almost always be on (e.g.
analyze_signature_compatibility
) from the output ofphan --init
(#3660) - Allow
phan --init
to create config file withtarget_php_version
of'7.4'
or'8.0'
based on composer.json (#3671)
๐ New Features(Analysis):
- ๐ Infer that merging defined variables with possibly undefined variables is also possibly undefined. (#1942)
- โ Add a fallback when some types of conditional check results in a empty union type in a loop:
If all types assigned to the variable in a loop in a function are known,
then try applying the condition to the union of those types. (#3614)
(This approach was chosen because it needs to run only once per function) - Infer that assignment operations (e.g.
+=
) create variables if they were undefined. - Properly infer that class constants that weren't literal int/float/strings have real type sets in their union types.
- Normalize union types of generic array elements after fetching
$x[$offset]
.
(e.g. changebool|false|null
to?bool
) - Normalize union types of result of
??
operator. - ๐ Fix false positives in redundant condition detection for the real types of array accesses. (#3638, #3645, #3650)
- ๐ Support the
non-empty-string
type in phpdoc comments (neither''
nor'0'
).
Warn about redundant/impossible checks ofnon-empty-string
. - ๐ Support the
non-zero-int
type in phpdoc comments. Infer it in real types and warn about redundant checks for zero/truthiness. - ๐ Support the the
non-empty-mixed
in phpdoc comments and in inferences. - ๐ Fix false positives possibly undefined variable warnings after conditions
such asif (X || count($x = []))
,if (X && preg_match(..., $matches))
, etc.
๐ Bug fixes:
- ๐ Fix a crash analyzing assignment operations on
$GLOBALS
such as$GLOBALS['var'] += expr;
(#3615) - ๐ Fix false positive
Phan[Possibly]UndeclaredGlobalVariable
after conditions such asassert($var instanceof MyClass
when the variable was not assigned to within the file or previously analyzed files. (#3616) - ๐ Fix line number of 0 for some nodes when
simplify_ast
is enabled. (#3649)
๐ Plugins:
- ๐ Make Phan use the real type set of the return value of the function being analyzed when plugins return a union type without a real type set.
๐ง Maintenance:
- Infer that
explode()
is possibly the empty list when$limit
is possibly negative. (#3617) - ๐
Make Phan's code follow more PSR-12 style guidelines
(<?php
on its own line,function(): T
instead offunction() : T
, declare visibility for class constants) - Internal: Check if strings are non-zero length in Phan's implementation instead of checking for variable truthiness.
('0'
is falsey) - ๐ Show
null
as lowercase instead of uppercase (the wayvar_export
renders it) in more places.
- Add an environment variable
-
v2.4.6 Changes
December 29, 2019๐ New features(CLI, Configs):
- โ Add more detailed instructions for installing dependencies new php installations on Windows without a php.ini
- ๐ Handle being installed in a non-standard composer directory name (i.e. not
vendor
) (mentioned in #1612)
๐ New Features(Analysis):
- ๐ Improve inferred array shapes for multi-dimensional assignments or conditions on arrays
(e.g.$x['first']['second'] = expr
orif (cond($x['first']['second']))
) (#1510, #3569) - Infer that array offsets are no longer possibly undefined after conditions such as
if (!is_null($x['offset']))
- ๐ Improve worst-case runtime when merging union types with many types (#3587)
- ๐ Improve analysis of assignment operators. (#3597)
- Infer
$x op= expr
and++
/--
operators have a literal value when possible, outside of loops. (#3250, #3248) - ๐ Move
PhanUndeclaredInterface
andPhanUndeclaredTrait
warnings to the line number of theuse
/implements
. (#2159) - Don't emit
PhanUndeclaredGlobalVariable
for the left side of??
/??=
in the global scope (#3601) - More consistently infer that variables are possibly undefined if they are not defined in all branches. (#1345, #1942)
- โ Add new issue types for possibly undeclared variables:
PhanPossiblyUndeclaredVariable
andPhanPossiblyUndeclaredGlobalVariable
.
๐ Plugins:
- โ Add
StrictLiteralComparisonPlugin
to warn about loose equality comparisons of constant string/int to other values. (#2310)
๐ Bug fixes:
-
v2.4.5 Changes
December 11, 2019๐ Plugins:
- ๐ When adding a plugin overriding the return type of a method,
๐ make it affect all methods of descendant classlikes that inherited that method definition.
๐ New Features(Analysis)
- Infer that
!empty($x['field']...)
also implies$x['field']
is non-falsey. (#3570)
๐ Bug fixes:
Fix bug in native parsing of
AST_TYPE_UNION
(union type) nodes for PHP 8.0.0-dev.๐จ Don't print duplicate entries for functions with alternate signatures in
tool/make_stubs
๐ Fix Error parsing internal template types such as
non-empty-list<string>
when usingType::fromFullyQualifiedString()
.๐ Fix warnings about
password_hash()
algorithm constants with php 7.4 (#3560)
0๏ธโฃPASSWORD_DEFAULT
became null in php 7.4, and other constants became strings.Note that you will need to run Phan with both php 7.4 and a
target_php_version
of 7.4 to fix the errors.๐ Fix uncaught
AssertionError
when parsing@return \\...
(#3573) - ๐ When adding a plugin overriding the return type of a method,
-
v2.4.4 Changes
November 24, 2019๐ New features(CLI, Configs):
0๏ธโฃ When stderr is redirected a file or to another program, show an append-only progress bar by default. (#3514)
0๏ธโฃ Phan would previously disable the progress bar entirely by default.The new
--long-progress-bar
CLI flag can be used to choose this progress bar.(The
--no-progress-bar
CLI flag or the environment variablePHAN_DISABLE_PROGRESS_BAR=1
can be used to disable this)Treat
$var = $x['possibly undefined offset']
as creating a definitely defined variable,
not a possibly undefined variable. (#3534)The config setting
convert_possibly_undefined_offset_to_nullable
controls
whether the field type gets cast to the nullable equivalent after removing undefined.๐ New features(Analysis):
- Emit
PhanPossiblyUndefinedArrayOffset
for accesses to array fields that are possibly undefined. (#3534) - Warn about returning/not returning in void/non-void functions.
๐ New issue types:PhanSyntaxReturnValueInVoid
,PhanSyntaxReturnExpectedValue
- Infer that
$var[$offset] = expr;
/$this->prop[$offset] = expr;
causes that element to be non-null (#3546) - Emit
PhanEmptyForeachBody
when iterating over a type that isn'tTraversable
with an empty statement list. - Warn about computing
array_values
for an array that is already a list. (#3540) - Infer the real type is still an array after assigning to a field of an array.
๐ Plugins:
- ๐ In
DuplicateExpressionPlugin
, emitPhanPluginDuplicateIfStatements
if the body forelse
is identical to the above body for theif/elseif
.
๐ง Maintenance:
- Support native parsing of
AST_TYPE_UNION
(union type) nodes for PHP 8.0.0-dev. - โฌ๏ธ Reduce memory usage after the polyfill/fallback parser parses ASTs
(when the final AST isn't cached on disk from a previous run) - ๐ Make the error message for missing
php-ast
contain more detailed instructions on how to installphp-ast
.
- Emit
-
v2.4.3 Changes
November 21, 2019๐ New features(CLI, Configs):
- ๐ Support
NO_COLOR
environment variable. (https://no-color.org/)
When this variable is set, Phan's error message and issue text will not be colorized unless the CLI arg--color
or-c
is used.
This overrides thePHAN_ENABLE_COLOR_OUTPUT
setting. - Add
PHAN_DISABLE_PROGRESS_BAR
environment variable to disable progress bar by default unless the CLI arg--progress-bar
is used. - ๐ Show an extra decimal digit of precision in the progress bar when the terminal is wide enough. (#3514)
๐ New features(Analysis):
๐ Make inferred real types more accurate for equality/identity/instanceof checks.
๐ Combine array shape types into a single union type when merging variable types from multiple branches. (#3506)
๐ท Do a better job of invalidating the real union type of fields of array shape types when the field is only checked/set on some code branches.๐ Make issue suggestions (and CLI suggestions) for completions of prefixes case-insensitive.
๐ Support
@seal-properties
and@seal-methods
as aliases of@phan-forbid-undeclared-magic-properties
and@phan-forbid-undeclared-magic-methods
More aggressively infer real types of array destructuring(e.g.
[$x] = expr
) and accesses of array dimensions (e.g.$x = expr[dim]
) (#3481)This will result in a few more false positives about potentially real redundant/impossible conditions and real type mismatches.
๐ Fix false positives caused by assuming that the default values of properties are the real types of properties.
โ Infer that globals used in functions (
global $myGlobal;
) have unknown real types - don't emit warnings about redundant/impossible conditions. (#3521)๐ Plugins:
- ๐ Also start checking if closures (and arrow functions) can be static in
PossiblyStaticMethodPlugin
- โ Add
AvoidableGetterPlugin
to suggest when$this->prop
can be used instead of$this->getProp()
.
(This will suggest using the property instead of the getter method if there are no known method overrides of the getter. This is only checked for instance properties of$this
) - ๐ Increase severity of
PhanPluginPrintfNonexistentArgument
to critical. It will become an ArgumentCountError in PHP 8.
๐ง Maintenance:
- โฌ๏ธ Bump minimum version of netresearch/jsonmapper to avoid php notices in the language server in php 7.4
- ๐ Improve worst-case performance when analyzing code that has many possible combinations of array shapes.
๐ Bug fixes:
- โ Properly emit redundant and impossible condition warnings about uses of class constants defined as literal strings/floats/integers.
(i.e. infer their real union types) - ๐ Fix false positive inference that
$x[0]
wasstring
for$x
of types such aslist<\MyClass>|string
(reported in #3483) - Consistently inherit analysis settings from parent classes recursively, instead of only inheriting them from the direct parent class. (#3472)
(settings include presence of dynamic properties, whether undeclared magic methods are forbidden, etc.) - Don't treat methods that were overridden in one class but inherited by a different class as if they had overrides.
- ๐ Fix a crash when running in php 8.0.0-dev due to Union Types being found in Reflection. (#3503)
- ๐ Fix edge case looking up the
extends
class/interface name when the namespace is ause
alias (#3494)
- ๐ Support