Releases: phan/phan
Release 5.5.0 supporting PHP 7.0-8.4 syntax
New features(Analysis):
- Update real signatures of internal functions for PHP 8.1, add version for PHP 8.2, 8.3, and 8.4. #4960
- Support dynamic class constant fetch in PHP >= 8.3.
New issue type,PhanTypeInvalidConstantName
, emitted when the dynamic constant name cannot be a string. #4963 - Add basic support for deep-cloning of readonly properties
in PHP >= 8.3. #4962 - Warn when a subclass of a generic class does not use
@extends
or@inherit
to substitute template types #4993
New issue type:PhanGenericMissingParameters
- New plugin,
AsymmetricVisibilityPlugin
to analyze properties with asymmetric visibility when running in PHP 8.4.
New issue types:PhanPluginAsymmetricVisibilityNoType
,PhanPluginAsymmetricVisibilityLessRestrictive
#4996
Bug fixes:
- Fix type inference for properties with a PHPDoc type of
static
in assignments #4883 - Fix type inference for
json_decode
returning objects vs associative arrays #4745 - Fix infinite loop detection with calls to
openssl_error_string
,ob_get_level
, anderror_get_last
#4971 - Do not emit
PhanPossiblyInfiniteRecursionSameParams
if an array element or object property was modified #4972 - Do not treat
non-empty-string
as a subtype ofcallable-string
. Treatcallable-array
as a subtype ofnon-empty-array
#4974 - Properly infer template types when analyzing property assignments #4987
- Fix edge cases when parsing generic types #4992
- Do not infer all iterator key/value types from PHPDoc as real types #4986
Miscellaneous:
- Update PHP >= 8.1 signatures of internal functions for resource to object migration #4960
- Emit
PhanTypeInvalidDimOffset
when accessing a string offset of a union type containingstring
#4709 - Mark
imap_header()
as removed in PHP 8.0 - Infer key/element types more accurately for callable-array #4977
- Infer parameter default type more accurately #4398
Plugins:
- Fix PHPDocToRealTypesPlugin suggesting union types containing
mixed
as a non-standalone type #4952 - Make PHPDocRedundantPlugin detect redundant
@param
annotations.
This only warns if all the@param
are redundant, and does not flag individual redundant parameters. #4955 - Make UseReturnValuePlugin not require using the return value of
similar_text
when the&$percent
argument is passed. #4979 #4981
Release 5.4.6 supporting PHP 7.0-8.4 syntax
New features(Analysis):
- Infer that
json_encode
always returns a string in PHP >= 7.3 whenJSON_THROW_ON_ERROR
is used #4946
New features(CLI, Configs):
- Allow passing
--minimum-target-php-version=native
from the command line. #4939
Bug fixes:
- Fix type of the
$gc
argument tosession_set_save_handler
#4891 - Update various
IntlDateFormatter
signatures #4898 - Fix various false positives when using
enable_class_alias_support
and two aliases refer to each other #4897 - Fix deprecation warnings when using the CSV printer in PHP 8.4 #4913
- Fix false positive
PhanParamTooFewInternal
withexit()
in PHP 8.4 #4888 - Fix edge case false positives for inferred type of properties of
$this
#4916 - Fix false positive
PhanPossiblyUndeclaredVariable
in loops when redundant condition detection is enabled #4885, #4617 - Fix crash in PHP >= 8.3 due to increment or decrement on non-literal strings #4860
Plugins:
- Fix
dir()
andgetdir()
being reversed in DeprecateAliasPlugin #4882 - Make PHPDocRedundantPlugin handle magic methods #4931
- Fix UnknownElementTypePlugin flagging variadic parameters with
mixed
type #4927 - Update PHPDocToRealTypesPlugin for PHP 8 #4936
Miscellaneous:
- Require php-ast 1.1.2 or newer in PHP 8.4+ if php-ast is installed. #4895
- Support automatically setting target PHP version from composer.json for PHP >= 8.2 #4903, #4940
- Allow netresearch/jsonmapper ^5.0 #4901
- Update tests for PHP 8.4 #4902, #4907, #4909, #4911
#4912, #4917, #4923, #4925, #4934 - Support analyzing
exit()
in PHP 8.4 #4908 - Consistently disable the garbage collector for all entry points #4928
Release 5.4.5 supporting PHP 7.0-8.2 syntax
New features(Analysis):
- Emit
PhanDeprecatedImplicitNullableParam
for uses of implicitly nullable parameters (int $x = null
instead of?int $x = null
). These can be fixed automatically via the accompanying IssueFixer. #4875
New features(CLI, Configs):
-
Add
override_return_types
to add types to all return types. Normally, Phan only adds inferred returned types when there is no@return
type
or real return type signature. This setting can be disabled on individual methods by adding
@phan-hardcode-return-type
to the doc comment.Disabled by default. This is more useful with
--analyze-twice
and in conjunction withPhoundPlugin
to
detect more callsite possibilities. See the PR description where
this setting was added for more details.(Default:
false
)Along with this change, we are analyzing the return types of traits a bit more aggressively now. #4874
Bug fixes:
- Fix crash in PHP 8.4 due to deprecation warning about implicitly nullable parameters #4875
Maintenance:
- Update download links for php-ast zip files #4876
Release 5.4.4 supporting PHP 7.0-8.2 syntax
New features:
- New plugin PhoundPlugin to populate a sqlite database with callsites of all class elements. The database can be queried to find callsites of a given class element. This was actually introduced in 5.4.3, but not announced at the time. #18
- In 5.4.4, the accuracy of PhoundPlugin is improved by giving it access to the full method, property, and constant list that phan infers for a given callsite #4865
Miscellaneous:
- Fix DOMNode::insertBefore method signature #4837
- Update Google\Protobuf\Internal\Message::mergeFromJsonString method signature #4840
- Update fputcsv function signature #4856
- Update preg_replace_* function signatures #4856
- Update ReflectionClass::getConstants and ReflectionObject::getConstants method signatures #4861
- Add support to column position on file location in CodeClimatePrinter #4862
Release 5.4.3 supporting PHP 7.0-8.2 syntax
New Features(Analysis):
- Automatically inherit
@throws
types from parent methods ifenable_phpdoc_types
is true (which it is by default). (#4757)
Miscellaneous:
- Fix ldap function signatures
- Fix a couple of array spread crash bugs
- Extend supported dependency versions of symfony/console to also allow 7.x (#4822)
- Require php-ast 1.1.1 or newer in PHP 8.3+ if php-ast is installed.
Bug fixes:
- Fix interfaces can extend BackedEnum and UnitEnum (#4782)
- Fix ini_set() signature to take any scalar since PHP 8.1 (#4806)
- Fix RedisCluster setOption/getOption signatures (#4790)
- Don't emit
PhanTypeMismatchUnpackKeyArraySpread
whenminimum_target_php_version
is'8.1'
or newer. (#4788) - Fix a couple of array spread crash bugs (#4780)
- Fix crash if match is used inside for-loop (#4767)
- Fix DateTime::getTimestamp return type (#4731)
- Avoid deprecation warning for ASSERT constants in php 8.3+ (#4808)
- Use
ini_set()
instead ofassert_options()
when Phan's assertion options match PHP's assert ini setting defaults to keep those values and avoid deprecation warnings in php 8.3+. - Fix crash in AST fallback parser when parsing invalid ArgumentExpression in php 8.0+
- Fix false positive warnings and skipping internal constants declared by PECLs prefixed with
\x00
(APCu
,immutable_cache
)
This release fixes errors and deprecations seen running Phan with PHP 8.3, but it does not support analyzing most new syntax/features/changes deprecations of PHP 8.3 itself.
Release 5.4.2 supporting PHP 7.0-8.2 syntax
Miscellaneous:
- Fix wording in
EmptyStatementListPlugin
issue messages. - Add a few more functions where the return value should be used.
- Fix signature of
exif_read_data()
(#4759) - Make
allow_missing_properties
setting aware ofAllowDynamicProperties
attribute for PHP 8.2
Maintenance:
- Require php-ast 1.1.0 or newer in PHP 8.2+ if php-ast is installed.
This release of php-ast makes the parsing ofAST_ARROW_FUNC
in php 8.2 match older php versions. - Support parsing of PHP 8.2 syntax such as disjunctive normal form types and
readonly
classes in the polyfill/fallback parser. - Fix bugs parsing
__halt_compiler()
in the polyfill/fallback parser.
Release 5.4.1 supporting PHP 7.0-8.1 syntax
New Features(Analysis):
- Support parsing php 8.2's disjunctive normal form types (e.g.
A|(B&C)
(https://wiki.php.net/rfc/dnf_types). (#4699) - Support php 8.2 class constants on trait RFC. (#4687)
EmitPhanCompatibleTraitConstant
when using constants on traits with aminimum_target_php_version
below'8.2'
EmitPhanAccessClassConstantOfTraitDirectly
when directly referencing the class constant on the trait declaration. - Emit
PhanTypeModifyImmutableObjectProperty
for PHP 8.1readonly
properties when modified anywhere outside of the
declaring class's scope. (#4710)
Miscellaneous:
- Allow
array_filter
$callback
to be null (#4715)
Release 5.4.0 supporting PHP 7.0-8.1 syntax
New Features(CLI, Configs):
- Add
tool/analyze_phpt
to analyze phpt files. See https://www.phpinternalsbook.com/tests/phpt_file_structure.html
New Features(Analysis):
- Support php 8.2's
true
type (https://wiki.php.net/rfc/true-type).
EmitPhanCompatTrueType
whentrue
is used whenminimum_target_php_version
is less than 8.2. - Emit
PhanCompatStandaloneType
instead ofPhanInvalidNode
for uses of null/false as real standalone types to support php 8.2 https://wiki.php.net/rfc/null-false-standalone-types
(Not emitted whenminimum_target_php_version
is 8.2 or higher) - Improve support for php 8.2 readonly classes and php 8.1 readonly properties
Bug fixes:
- Fix php 8.2.0-dev deprecation notice for
ast\Node
when running Phan in php 5.2.0 with the polyfill instead of the native php-ast version. - Fix DuplicateArrayKeyPlugin "Implicit conversion from float ... to int" warning causing crash in php 8.1 (#4666)
- Fix slow memory leak of reference cycles in the language server - enable garbage collection for the Phan daemon/language server consistently. (#4665)
(This fix is only enabled in php 7.3+ when using pcntl, the pcntl fallback already re-enabled garbage collection. php 7.3 improved the garbage collection efficiency for large collections of objects.) - Move
PhanGenericConstructorTypes
warning to the class inheriting a constructor if needed (#4675) - Fix crash when combining types for null and an array with PHP_INT_MAX as a key (#4688)
- Fix incorrect type inference for arrays with keys that were invalid UTF-8 (#4688)
- Fix error due to deprecation notice running Phan in php 8.2 due to use of
"${}"
string interpolation (#4692)
Release 5.3.2 supporting PHP 7.0-8.1 syntax
New Features(Analysis):
- Use intersection type of original variable value and array elements when inferring type of
$var
inin_array($var, $array)
instead of just the type of the array elements (#4630) - Treat type of concatenation of one or more non-real strings as a phpdoc(non-real) string with the real type string. (#4635)
- In
phan --init
, allow inferring php 8.1 as the target php version in the generated config file. (#4655)
Maintenance:
- Allow installing xdebug-handler version ^3.0 (#4639)
- Allow installing symfony/console version ^6.0 (#4642)
Bug fixes:
-
Fix AST download link for PHP 8.0+ for Windows (#4645)
-
Fix dead code detection for PHP 8.0 non-capturing catch statements. (#4633)
This should still analyze the catch body even if there is no caught exception variable. -
Ignore phpdoc comment tags that don't start at the start of a line of the doc comment (
* @sometag
) or aren't an inline tag (* something {@sometag}
). (#4640)
See https://docs.phpdoc.org/3.0/guide/references/phpdoc/tags/internal.html and https://docs.phpdoc.org/2.9/guides/docblocks.htmlE.g.
* This is not @abstract.
is no longer treated as an abstract method.
Release 5.3.1 supporting PHP 7.0-8.1 syntax
New Features(Analysis):
- Emit
PhanDeprecatedPartiallySupportedCallable
for functions that work withcall_user_func($expr)
but not$expr()
.
The literal strings'self'
,'parent'
, and'static'
in'self::methodName'
or['self', 'methodName']
in callables were deprecated in PHP 8.2. - Emit
PhanDeprecatedPartiallySupportedCallableAlternateScope
for uses of callables such as[new SubClass(), 'Base::method']
specifying an alternate scope. - Make pass-by-ref vars result in a merged union type, not an overwritten one. (#4602)
Plugins:
- Update format string message for
PhanPluginUnknownClosureParamType
andPhanPluginUnknownFunctionParamType
.
Bug fixes:
- Avoid crashing when running in PHP 8.2+ after php 8.2 deprecated dynamic(undeclared) properties on classes without
#[AllowDynamicProperties]
.