phan v2.4.7 Release Notes
Release Date: 2020-01-23 // about 4 years ago-
๐ 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