New Features (Analysis):
-
Partially support php 8.1 enums (#4313)
(infer the real type is the class type, that they cannot be instantiated, that enum values cannot be reused, and that class constants will exist for enum cases)New issue types:
PhanReusedEnumCaseValue
,PhanTypeInstantiateEnum
,PhanTypeInvalidEnumCaseType
,PhanSyntaxInconsistentEnum
,
PhanInstanceMethodWithNoEnumCases
,PhanInstanceMethodWithNoEnumCases
,PhanEnumCannotHaveProperties
,PhanUnreferencedEnumCase
,
PhanEnumForbiddenMagicMethod
. -
Support php 7.4 covariant return types and contravariant parameter types when the configured or inferred
minimum_target_php_version
is'7.4'
or newer (#3795) -
Add initial support for the php 8.1
never
type (in real return types and phpdoc). (#4380)
Also add support for the phpdoc aliasesno-return
,never-return
, andnever-returns
-
Support casting
iterable<K, V>
toTraversable<K, V>
withis_object
or!is_array
checks -
Detect more types of expressions that never return when inferring types (e.g. when analyzing
?:
,??
operators) -
Use php 8.1's tentative return types from reflection (
hasTentativeReturnType
,getTentativeReturnType
) to assume real return types of internal functions/methods (#4400)This can be disabled by setting
use_tentative_return_type
tofalse
(e.g. when using subclasses of internal classes that return incompatible types). -
Warn about modifying properties of classes that are immutable at runtime (enums, internal classes such as
\Closure
and\WeakRef
, etc.) (#4313)
New issue type:PhanTypeModifyImmutableObjectProperty
Dead code detection:
-
Infer that functions with a return type of
never
(or phpdoc aliases such asno-return
) are unreachable when performing control flow analysis.
This can be disabled by settingdead_code_detection_treat_never_type_as_unreachable
to falseNote that control flow is only affected when
UseReturnValuePlugin
is enabled.
Plugins:
- In
UseReturnValuePlugin
, also start warning about when using the result of an expression that evaluates tonever
New issue types:PhanUseReturnValueOfNever
Bug fixes:
-
As part of the work on php 7.4 contravariant parameter types,
don't automatically inherit inferred parameter types from ancestor classlikes when (1) there is no@param
tag with a type for the parameter on the overriding method and (2) the ancestor parameter types are a subtype of the real parameter types unless@inheritDoc
is used.- This is a generic array type such as
array<string,mixed>
that is a specialization of an array type.
If you want to indicate that the overriding method can be any array type, add@param array $paramName
.
-
Change composer.json dependency on
composer/xdebug-handler
from^2.0
to^1.1|2.0
to avoid conflicting with other libraries or applications that depend on xdebug-handler 1.x (#4382) -
Support parsing multiple declare directives in the polyfill/fallback parser (#4160)