From 26e238cdc5d3896bba3715a9182b4e9d62fae6ee Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 10 Feb 2022 01:44:25 +0200 Subject: [PATCH 1/3] Finalize types nodes --- src/Psalm/Type/Atomic/TAnonymousClassInstance.php | 2 +- src/Psalm/Type/Atomic/TCallable.php | 2 +- src/Psalm/Type/Atomic/TCallableArray.php | 2 +- src/Psalm/Type/Atomic/TCallableKeyedArray.php | 2 +- src/Psalm/Type/Atomic/TCallableList.php | 2 +- src/Psalm/Type/Atomic/TCallableObject.php | 2 +- src/Psalm/Type/Atomic/TCallableString.php | 2 +- src/Psalm/Type/Atomic/TClassConstant.php | 2 +- src/Psalm/Type/Atomic/TClassStringMap.php | 2 +- src/Psalm/Type/Atomic/TClosedResource.php | 2 +- src/Psalm/Type/Atomic/TClosure.php | 2 +- src/Psalm/Type/Atomic/TConditional.php | 2 +- src/Psalm/Type/Atomic/TDependentGetClass.php | 2 +- src/Psalm/Type/Atomic/TDependentGetDebugType.php | 2 +- src/Psalm/Type/Atomic/TDependentGetType.php | 2 +- src/Psalm/Type/Atomic/TDependentListKey.php | 2 +- src/Psalm/Type/Atomic/TEmptyMixed.php | 2 +- src/Psalm/Type/Atomic/TEmptyNumeric.php | 2 +- src/Psalm/Type/Atomic/TEmptyScalar.php | 2 +- src/Psalm/Type/Atomic/TEnumCase.php | 2 +- src/Psalm/Type/Atomic/TFalse.php | 2 +- src/Psalm/Type/Atomic/TGenericObject.php | 2 +- src/Psalm/Type/Atomic/TIntMask.php | 2 +- src/Psalm/Type/Atomic/TIntMaskOf.php | 2 +- src/Psalm/Type/Atomic/TIntRange.php | 2 +- src/Psalm/Type/Atomic/TIterable.php | 2 +- src/Psalm/Type/Atomic/TKeyOfArray.php | 2 +- src/Psalm/Type/Atomic/TLiteralClassString.php | 2 +- src/Psalm/Type/Atomic/TLiteralFloat.php | 2 +- src/Psalm/Type/Atomic/TLiteralInt.php | 2 +- src/Psalm/Type/Atomic/TLowercaseString.php | 2 +- src/Psalm/Type/Atomic/TNever.php | 2 +- src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php | 2 +- src/Psalm/Type/Atomic/TNonEmptyMixed.php | 2 +- src/Psalm/Type/Atomic/TNonEmptyNonspecificLiteralString.php | 2 +- src/Psalm/Type/Atomic/TNonEmptyScalar.php | 2 +- src/Psalm/Type/Atomic/TNonspecificLiteralInt.php | 2 +- src/Psalm/Type/Atomic/TNull.php | 2 +- src/Psalm/Type/Atomic/TNumericString.php | 2 +- src/Psalm/Type/Atomic/TObjectWithProperties.php | 2 +- src/Psalm/Type/Atomic/TResource.php | 2 +- src/Psalm/Type/Atomic/TSingleLetter.php | 2 +- src/Psalm/Type/Atomic/TTemplateIndexedAccess.php | 2 +- src/Psalm/Type/Atomic/TTemplateKeyOf.php | 2 +- src/Psalm/Type/Atomic/TTemplateParam.php | 2 +- src/Psalm/Type/Atomic/TTemplateParamClass.php | 2 +- src/Psalm/Type/Atomic/TTemplateValueOf.php | 2 +- src/Psalm/Type/Atomic/TTraitString.php | 2 +- src/Psalm/Type/Atomic/TTrue.php | 2 +- src/Psalm/Type/Atomic/TTypeAlias.php | 2 +- src/Psalm/Type/Atomic/TValueOfArray.php | 2 +- src/Psalm/Type/Atomic/TVoid.php | 2 +- src/Psalm/Type/TaintKind.php | 2 +- src/Psalm/Type/TaintKindGroup.php | 2 +- src/Psalm/Type/Union.php | 2 +- 55 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php index 5c066a03d8f..1a29e4d27a4 100644 --- a/src/Psalm/Type/Atomic/TAnonymousClassInstance.php +++ b/src/Psalm/Type/Atomic/TAnonymousClassInstance.php @@ -5,7 +5,7 @@ /** * Denotes an anonymous class (i.e. `new class{}`) with potential methods */ -class TAnonymousClassInstance extends TNamedObject +final class TAnonymousClassInstance extends TNamedObject { /** * @var string|null diff --git a/src/Psalm/Type/Atomic/TCallable.php b/src/Psalm/Type/Atomic/TCallable.php index 217c717fe00..c0dc900af9e 100644 --- a/src/Psalm/Type/Atomic/TCallable.php +++ b/src/Psalm/Type/Atomic/TCallable.php @@ -7,7 +7,7 @@ /** * Denotes the `callable` type. Can result from an `is_callable` check. */ -class TCallable extends Atomic +final class TCallable extends Atomic { use CallableTrait; diff --git a/src/Psalm/Type/Atomic/TCallableArray.php b/src/Psalm/Type/Atomic/TCallableArray.php index 1ccce11b80e..4dba9674653 100644 --- a/src/Psalm/Type/Atomic/TCallableArray.php +++ b/src/Psalm/Type/Atomic/TCallableArray.php @@ -5,7 +5,7 @@ /** * Denotes an array that is _also_ `callable`. */ -class TCallableArray extends TNonEmptyArray +final class TCallableArray extends TNonEmptyArray { /** * @var string diff --git a/src/Psalm/Type/Atomic/TCallableKeyedArray.php b/src/Psalm/Type/Atomic/TCallableKeyedArray.php index 0e6175b3ba9..91c89e0600e 100644 --- a/src/Psalm/Type/Atomic/TCallableKeyedArray.php +++ b/src/Psalm/Type/Atomic/TCallableKeyedArray.php @@ -5,7 +5,7 @@ /** * Denotes an object-like array that is _also_ `callable`. */ -class TCallableKeyedArray extends TKeyedArray +final class TCallableKeyedArray extends TKeyedArray { public const KEY = 'callable-array'; diff --git a/src/Psalm/Type/Atomic/TCallableList.php b/src/Psalm/Type/Atomic/TCallableList.php index 237e70cf0c9..1429d36ed0e 100644 --- a/src/Psalm/Type/Atomic/TCallableList.php +++ b/src/Psalm/Type/Atomic/TCallableList.php @@ -5,7 +5,7 @@ /** * Denotes a list that is _also_ `callable`. */ -class TCallableList extends TNonEmptyList +final class TCallableList extends TNonEmptyList { public const KEY = 'callable-list'; } diff --git a/src/Psalm/Type/Atomic/TCallableObject.php b/src/Psalm/Type/Atomic/TCallableObject.php index 5657a51cf0c..2bb7e3b2791 100644 --- a/src/Psalm/Type/Atomic/TCallableObject.php +++ b/src/Psalm/Type/Atomic/TCallableObject.php @@ -5,7 +5,7 @@ /** * Denotes an object that is also `callable` (i.e. it has `__invoke` defined). */ -class TCallableObject extends TObject +final class TCallableObject extends TObject { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TCallableString.php b/src/Psalm/Type/Atomic/TCallableString.php index d2bf403bd41..e008efa511c 100644 --- a/src/Psalm/Type/Atomic/TCallableString.php +++ b/src/Psalm/Type/Atomic/TCallableString.php @@ -5,7 +5,7 @@ /** * Denotes the `callable-string` type, used to represent an unknown string that is also `callable`. */ -class TCallableString extends TNonFalsyString +final class TCallableString extends TNonFalsyString { public function getKey(bool $include_extra = true): string diff --git a/src/Psalm/Type/Atomic/TClassConstant.php b/src/Psalm/Type/Atomic/TClassConstant.php index cb357453dff..79bd6497246 100644 --- a/src/Psalm/Type/Atomic/TClassConstant.php +++ b/src/Psalm/Type/Atomic/TClassConstant.php @@ -8,7 +8,7 @@ /** * Denotes a class constant whose value might not yet be known. */ -class TClassConstant extends Atomic +final class TClassConstant extends Atomic { /** @var string */ public $fq_classlike_name; diff --git a/src/Psalm/Type/Atomic/TClassStringMap.php b/src/Psalm/Type/Atomic/TClassStringMap.php index 584883e0164..aadcad0b7ce 100644 --- a/src/Psalm/Type/Atomic/TClassStringMap.php +++ b/src/Psalm/Type/Atomic/TClassStringMap.php @@ -17,7 +17,7 @@ * Represents an array where the type of each value * is a function of its string key value */ -class TClassStringMap extends Atomic +final class TClassStringMap extends Atomic { /** * @var string diff --git a/src/Psalm/Type/Atomic/TClosedResource.php b/src/Psalm/Type/Atomic/TClosedResource.php index b8b2bc1811e..5d4828fbf25 100644 --- a/src/Psalm/Type/Atomic/TClosedResource.php +++ b/src/Psalm/Type/Atomic/TClosedResource.php @@ -7,7 +7,7 @@ /** * Denotes the `resource` type that has been closed (e.g. a file handle through `fclose()`). */ -class TClosedResource extends Atomic +final class TClosedResource extends Atomic { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TClosure.php b/src/Psalm/Type/Atomic/TClosure.php index 7703aa82cb7..fda5f17726e 100644 --- a/src/Psalm/Type/Atomic/TClosure.php +++ b/src/Psalm/Type/Atomic/TClosure.php @@ -5,7 +5,7 @@ /** * Represents a closure where we know the return type and params */ -class TClosure extends TNamedObject +final class TClosure extends TNamedObject { use CallableTrait; diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php index 90f4bd9d0b4..070f7ac2d71 100644 --- a/src/Psalm/Type/Atomic/TConditional.php +++ b/src/Psalm/Type/Atomic/TConditional.php @@ -11,7 +11,7 @@ /** * Internal representation of a conditional return type in phpdoc. For example ($param1 is int ? int : string) */ -class TConditional extends Atomic +final class TConditional extends Atomic { /** * @var string diff --git a/src/Psalm/Type/Atomic/TDependentGetClass.php b/src/Psalm/Type/Atomic/TDependentGetClass.php index 5f47b315aa7..b1aacc2ceb0 100644 --- a/src/Psalm/Type/Atomic/TDependentGetClass.php +++ b/src/Psalm/Type/Atomic/TDependentGetClass.php @@ -8,7 +8,7 @@ /** * Represents a string whose value is a fully-qualified class found by get_class($var) */ -class TDependentGetClass extends TString implements DependentType +final class TDependentGetClass extends TString implements DependentType { /** * Used to hold information as to what this refers to diff --git a/src/Psalm/Type/Atomic/TDependentGetDebugType.php b/src/Psalm/Type/Atomic/TDependentGetDebugType.php index 1bdf96486eb..aa51ceb6f84 100644 --- a/src/Psalm/Type/Atomic/TDependentGetDebugType.php +++ b/src/Psalm/Type/Atomic/TDependentGetDebugType.php @@ -7,7 +7,7 @@ /** * Represents a string whose value is that of a type found by get_debug_type($var) */ -class TDependentGetDebugType extends TString implements DependentType +final class TDependentGetDebugType extends TString implements DependentType { /** * Used to hold information as to what this refers to diff --git a/src/Psalm/Type/Atomic/TDependentGetType.php b/src/Psalm/Type/Atomic/TDependentGetType.php index 4b91601c33b..6d53ef62bbd 100644 --- a/src/Psalm/Type/Atomic/TDependentGetType.php +++ b/src/Psalm/Type/Atomic/TDependentGetType.php @@ -5,7 +5,7 @@ /** * Represents a string whose value is that of a type found by gettype($var) */ -class TDependentGetType extends TString +final class TDependentGetType extends TString { /** * Used to hold information as to what this refers to diff --git a/src/Psalm/Type/Atomic/TDependentListKey.php b/src/Psalm/Type/Atomic/TDependentListKey.php index 65d4a34e7d6..22f2e1c95bc 100644 --- a/src/Psalm/Type/Atomic/TDependentListKey.php +++ b/src/Psalm/Type/Atomic/TDependentListKey.php @@ -7,7 +7,7 @@ /** * Represents a list key created from foreach ($list as $key => $value) */ -class TDependentListKey extends TInt implements DependentType +final class TDependentListKey extends TInt implements DependentType { /** * Used to hold information as to what list variable this refers to diff --git a/src/Psalm/Type/Atomic/TEmptyMixed.php b/src/Psalm/Type/Atomic/TEmptyMixed.php index da93de38316..adbe375cfbd 100644 --- a/src/Psalm/Type/Atomic/TEmptyMixed.php +++ b/src/Psalm/Type/Atomic/TEmptyMixed.php @@ -6,7 +6,7 @@ * Denotes the `mixed` type, but empty. * Generated for `$x` inside the `if` statement `if (!$x) {...}` when `$x` is `mixed` outside. */ -class TEmptyMixed extends TMixed +final class TEmptyMixed extends TMixed { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TEmptyNumeric.php b/src/Psalm/Type/Atomic/TEmptyNumeric.php index 6d353e5da74..7199f6821e2 100644 --- a/src/Psalm/Type/Atomic/TEmptyNumeric.php +++ b/src/Psalm/Type/Atomic/TEmptyNumeric.php @@ -5,7 +5,7 @@ /** * Denotes the `numeric` type that's also empty (which can also result from an `is_numeric` and `empty` check). */ -class TEmptyNumeric extends TNumeric +final class TEmptyNumeric extends TNumeric { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TEmptyScalar.php b/src/Psalm/Type/Atomic/TEmptyScalar.php index 5df337e0d80..036d28bef1d 100644 --- a/src/Psalm/Type/Atomic/TEmptyScalar.php +++ b/src/Psalm/Type/Atomic/TEmptyScalar.php @@ -5,7 +5,7 @@ /** * Denotes a `scalar` type that is also empty. */ -class TEmptyScalar extends TScalar +final class TEmptyScalar extends TScalar { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TEnumCase.php b/src/Psalm/Type/Atomic/TEnumCase.php index 474d8bbe0a3..5522714948e 100644 --- a/src/Psalm/Type/Atomic/TEnumCase.php +++ b/src/Psalm/Type/Atomic/TEnumCase.php @@ -5,7 +5,7 @@ /** * Denotes an enum with a specific value */ -class TEnumCase extends TNamedObject +final class TEnumCase extends TNamedObject { /** * @var string diff --git a/src/Psalm/Type/Atomic/TFalse.php b/src/Psalm/Type/Atomic/TFalse.php index 108d0f1136e..e4b43a3170b 100644 --- a/src/Psalm/Type/Atomic/TFalse.php +++ b/src/Psalm/Type/Atomic/TFalse.php @@ -5,7 +5,7 @@ /** * Denotes the `false` value type */ -class TFalse extends TBool +final class TFalse extends TBool { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php index e7fe236f413..44f885e0757 100644 --- a/src/Psalm/Type/Atomic/TGenericObject.php +++ b/src/Psalm/Type/Atomic/TGenericObject.php @@ -14,7 +14,7 @@ /** * Denotes an object type that has generic parameters e.g. `ArrayObject` */ -class TGenericObject extends TNamedObject +final class TGenericObject extends TNamedObject { use GenericTrait; diff --git a/src/Psalm/Type/Atomic/TIntMask.php b/src/Psalm/Type/Atomic/TIntMask.php index 2042e4768b5..4d3dca8340a 100644 --- a/src/Psalm/Type/Atomic/TIntMask.php +++ b/src/Psalm/Type/Atomic/TIntMask.php @@ -8,7 +8,7 @@ * Represents the type that is the result of a bitmask combination of its parameters. * `int-mask<1, 2, 4>` corresponds to `0|1|2|3|4|5|6|7` */ -class TIntMask extends TInt +final class TIntMask extends TInt { /** @var non-empty-array */ public $values; diff --git a/src/Psalm/Type/Atomic/TIntMaskOf.php b/src/Psalm/Type/Atomic/TIntMaskOf.php index 86cb53b83ef..5130eecf1f0 100644 --- a/src/Psalm/Type/Atomic/TIntMaskOf.php +++ b/src/Psalm/Type/Atomic/TIntMaskOf.php @@ -9,7 +9,7 @@ * This is the same concept as TIntMask but TIntMaskOf is used with with a reference to constants in code * `int-mask` will corresponds to `0|1|2|3|4|5|6|7` if there are three constant 1, 2 and 4 */ -class TIntMaskOf extends TInt +final class TIntMaskOf extends TInt { /** @var TClassConstant|TKeyOfArray|TValueOfArray */ public $value; diff --git a/src/Psalm/Type/Atomic/TIntRange.php b/src/Psalm/Type/Atomic/TIntRange.php index 32254ae11fd..eec4e671f65 100644 --- a/src/Psalm/Type/Atomic/TIntRange.php +++ b/src/Psalm/Type/Atomic/TIntRange.php @@ -8,7 +8,7 @@ /** * Denotes an interval of integers between two bounds */ -class TIntRange extends TInt +final class TIntRange extends TInt { public const BOUND_MIN = 'min'; public const BOUND_MAX = 'max'; diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php index 927304971b4..ed8462a5924 100644 --- a/src/Psalm/Type/Atomic/TIterable.php +++ b/src/Psalm/Type/Atomic/TIterable.php @@ -14,7 +14,7 @@ /** * denotes the `iterable` type(which can also result from an `is_iterable` check). */ -class TIterable extends Atomic +final class TIterable extends Atomic { use HasIntersectionTrait; use GenericTrait; diff --git a/src/Psalm/Type/Atomic/TKeyOfArray.php b/src/Psalm/Type/Atomic/TKeyOfArray.php index 1839a370bb5..ca81cb26ccc 100644 --- a/src/Psalm/Type/Atomic/TKeyOfArray.php +++ b/src/Psalm/Type/Atomic/TKeyOfArray.php @@ -11,7 +11,7 @@ /** * Represents an offset of an array. */ -class TKeyOfArray extends TArrayKey +final class TKeyOfArray extends TArrayKey { /** @var Union */ public $type; diff --git a/src/Psalm/Type/Atomic/TLiteralClassString.php b/src/Psalm/Type/Atomic/TLiteralClassString.php index cfae6aab4ac..6339a5757b3 100644 --- a/src/Psalm/Type/Atomic/TLiteralClassString.php +++ b/src/Psalm/Type/Atomic/TLiteralClassString.php @@ -11,7 +11,7 @@ /** * Denotes a specific class string, generated by expressions like `A::class`. */ -class TLiteralClassString extends TLiteralString +final class TLiteralClassString extends TLiteralString { /** * Whether or not this type can represent a child of the class named in $value diff --git a/src/Psalm/Type/Atomic/TLiteralFloat.php b/src/Psalm/Type/Atomic/TLiteralFloat.php index b8d4c54837d..4e11468304f 100644 --- a/src/Psalm/Type/Atomic/TLiteralFloat.php +++ b/src/Psalm/Type/Atomic/TLiteralFloat.php @@ -5,7 +5,7 @@ /** * Denotes a floating point value where the exact numeric value is known. */ -class TLiteralFloat extends TFloat +final class TLiteralFloat extends TFloat { /** @var float */ public $value; diff --git a/src/Psalm/Type/Atomic/TLiteralInt.php b/src/Psalm/Type/Atomic/TLiteralInt.php index 4dfea9db9c7..390606ebb1b 100644 --- a/src/Psalm/Type/Atomic/TLiteralInt.php +++ b/src/Psalm/Type/Atomic/TLiteralInt.php @@ -5,7 +5,7 @@ /** * Denotes an integer value where the exact numeric value is known. */ -class TLiteralInt extends TInt +final class TLiteralInt extends TInt { /** @var int */ public $value; diff --git a/src/Psalm/Type/Atomic/TLowercaseString.php b/src/Psalm/Type/Atomic/TLowercaseString.php index ad8d1a045db..a9eecb9f362 100644 --- a/src/Psalm/Type/Atomic/TLowercaseString.php +++ b/src/Psalm/Type/Atomic/TLowercaseString.php @@ -2,7 +2,7 @@ namespace Psalm\Type\Atomic; -class TLowercaseString extends TString +final class TLowercaseString extends TString { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TNever.php b/src/Psalm/Type/Atomic/TNever.php index f7de8a3fd1b..b10bfc10cf6 100644 --- a/src/Psalm/Type/Atomic/TNever.php +++ b/src/Psalm/Type/Atomic/TNever.php @@ -8,7 +8,7 @@ * Denotes the `no-return`/`never-return` type for functions that never return, either throwing an exception or * terminating (like the builtin `exit()`). */ -class TNever extends Atomic +final class TNever extends Atomic { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php b/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php index cc6edbdbad8..52812e75783 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php +++ b/src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php @@ -5,7 +5,7 @@ /** * Denotes a non-empty-string where every character is lowercased. (which can also result from a `strtolower` call). */ -class TNonEmptyLowercaseString extends TNonEmptyString +final class TNonEmptyLowercaseString extends TNonEmptyString { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TNonEmptyMixed.php b/src/Psalm/Type/Atomic/TNonEmptyMixed.php index 35bb9076407..1b96eb47f88 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyMixed.php +++ b/src/Psalm/Type/Atomic/TNonEmptyMixed.php @@ -6,7 +6,7 @@ * Denotes the `mixed` type, but not empty. * Generated for `$x` inside the `if` statement `if ($x) {...}` when `$x` is `mixed` outside. */ -class TNonEmptyMixed extends TMixed +final class TNonEmptyMixed extends TMixed { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TNonEmptyNonspecificLiteralString.php b/src/Psalm/Type/Atomic/TNonEmptyNonspecificLiteralString.php index 6d4630c782e..4802a72a261 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyNonspecificLiteralString.php +++ b/src/Psalm/Type/Atomic/TNonEmptyNonspecificLiteralString.php @@ -6,7 +6,7 @@ * Denotes the `literal-string` type, where the exact value is unknown but * we know that the string is not from user input */ -class TNonEmptyNonspecificLiteralString extends TNonspecificLiteralString +final class TNonEmptyNonspecificLiteralString extends TNonspecificLiteralString { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TNonEmptyScalar.php b/src/Psalm/Type/Atomic/TNonEmptyScalar.php index f0e9ba43c87..ec3d56d6fb7 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyScalar.php +++ b/src/Psalm/Type/Atomic/TNonEmptyScalar.php @@ -5,7 +5,7 @@ /** * Denotes a `scalar` type that is also non-empty. */ -class TNonEmptyScalar extends TScalar +final class TNonEmptyScalar extends TScalar { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TNonspecificLiteralInt.php b/src/Psalm/Type/Atomic/TNonspecificLiteralInt.php index 90ac7892d03..08c2f4d7af8 100644 --- a/src/Psalm/Type/Atomic/TNonspecificLiteralInt.php +++ b/src/Psalm/Type/Atomic/TNonspecificLiteralInt.php @@ -6,7 +6,7 @@ * Denotes the `literal-int` type, where the exact value is unknown but * we know that the int is not from user input */ -class TNonspecificLiteralInt extends TInt +final class TNonspecificLiteralInt extends TInt { public function getId(bool $exact = true, bool $nested = true): string { diff --git a/src/Psalm/Type/Atomic/TNull.php b/src/Psalm/Type/Atomic/TNull.php index afbbf88293e..959a53d0e4a 100644 --- a/src/Psalm/Type/Atomic/TNull.php +++ b/src/Psalm/Type/Atomic/TNull.php @@ -7,7 +7,7 @@ /** * Denotes the `null` type */ -class TNull extends Atomic +final class TNull extends Atomic { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TNumericString.php b/src/Psalm/Type/Atomic/TNumericString.php index b4d23ec1423..8f2109ec0d0 100644 --- a/src/Psalm/Type/Atomic/TNumericString.php +++ b/src/Psalm/Type/Atomic/TNumericString.php @@ -5,7 +5,7 @@ /** * Denotes a string that's also a numeric value e.g. `"5"`. It can result from `is_string($s) && is_numeric($s)`. */ -class TNumericString extends TNonEmptyString +final class TNumericString extends TNonEmptyString { public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TObjectWithProperties.php b/src/Psalm/Type/Atomic/TObjectWithProperties.php index a69216820b6..2ae470848cc 100644 --- a/src/Psalm/Type/Atomic/TObjectWithProperties.php +++ b/src/Psalm/Type/Atomic/TObjectWithProperties.php @@ -20,7 +20,7 @@ /** * Denotes an object with specified member variables e.g. `object{foo:int, bar:string}`. */ -class TObjectWithProperties extends TObject +final class TObjectWithProperties extends TObject { use HasIntersectionTrait; diff --git a/src/Psalm/Type/Atomic/TResource.php b/src/Psalm/Type/Atomic/TResource.php index e564ebe4f82..e7ca229412c 100644 --- a/src/Psalm/Type/Atomic/TResource.php +++ b/src/Psalm/Type/Atomic/TResource.php @@ -7,7 +7,7 @@ /** * Denotes the `resource` type (e.g. a file handle). */ -class TResource extends Atomic +final class TResource extends Atomic { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TSingleLetter.php b/src/Psalm/Type/Atomic/TSingleLetter.php index 13db20248a7..80613302479 100644 --- a/src/Psalm/Type/Atomic/TSingleLetter.php +++ b/src/Psalm/Type/Atomic/TSingleLetter.php @@ -5,6 +5,6 @@ /** * Denotes a string that has a length of 1 */ -class TSingleLetter extends TString +final class TSingleLetter extends TString { } diff --git a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php index 22778e60988..ac3edfd4717 100644 --- a/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php +++ b/src/Psalm/Type/Atomic/TTemplateIndexedAccess.php @@ -4,7 +4,7 @@ use Psalm\Type\Atomic; -class TTemplateIndexedAccess extends Atomic +final class TTemplateIndexedAccess extends Atomic { /** * @var string diff --git a/src/Psalm/Type/Atomic/TTemplateKeyOf.php b/src/Psalm/Type/Atomic/TTemplateKeyOf.php index 8803f6586c6..9a679df4164 100644 --- a/src/Psalm/Type/Atomic/TTemplateKeyOf.php +++ b/src/Psalm/Type/Atomic/TTemplateKeyOf.php @@ -11,7 +11,7 @@ /** * Represents the type used when using TKeyOfArray when the type of the array is a template */ -class TTemplateKeyOf extends Atomic +final class TTemplateKeyOf extends Atomic { /** * @var string diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php index 3ce14741fbd..a19bffd8f92 100644 --- a/src/Psalm/Type/Atomic/TTemplateParam.php +++ b/src/Psalm/Type/Atomic/TTemplateParam.php @@ -13,7 +13,7 @@ /** * denotes a template parameter that has been previously specified in a `@template` tag. */ -class TTemplateParam extends Atomic +final class TTemplateParam extends Atomic { use HasIntersectionTrait; diff --git a/src/Psalm/Type/Atomic/TTemplateParamClass.php b/src/Psalm/Type/Atomic/TTemplateParamClass.php index 2a46c0a49ba..a64aadef247 100644 --- a/src/Psalm/Type/Atomic/TTemplateParamClass.php +++ b/src/Psalm/Type/Atomic/TTemplateParamClass.php @@ -5,7 +5,7 @@ /** * Denotes a `class-string` corresponding to a template parameter previously specified in a `@template` tag. */ -class TTemplateParamClass extends TClassString +final class TTemplateParamClass extends TClassString { /** * @var string diff --git a/src/Psalm/Type/Atomic/TTemplateValueOf.php b/src/Psalm/Type/Atomic/TTemplateValueOf.php index 02a520a6e17..68f1dacbce3 100644 --- a/src/Psalm/Type/Atomic/TTemplateValueOf.php +++ b/src/Psalm/Type/Atomic/TTemplateValueOf.php @@ -11,7 +11,7 @@ /** * Represents the type used when using TValueOfArray when the type of the array is a template */ -class TTemplateValueOf extends Atomic +final class TTemplateValueOf extends Atomic { /** * @var string diff --git a/src/Psalm/Type/Atomic/TTraitString.php b/src/Psalm/Type/Atomic/TTraitString.php index 59aa4f03c51..bb4cf93b684 100644 --- a/src/Psalm/Type/Atomic/TTraitString.php +++ b/src/Psalm/Type/Atomic/TTraitString.php @@ -5,7 +5,7 @@ /** * Denotes the `trait-string` type, used to describe a string representing a valid PHP trait. */ -class TTraitString extends TString +final class TTraitString extends TString { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TTrue.php b/src/Psalm/Type/Atomic/TTrue.php index 911b062278b..56b5b5ed63c 100644 --- a/src/Psalm/Type/Atomic/TTrue.php +++ b/src/Psalm/Type/Atomic/TTrue.php @@ -5,7 +5,7 @@ /** * Denotes the `true` value type */ -class TTrue extends TBool +final class TTrue extends TBool { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/Atomic/TTypeAlias.php b/src/Psalm/Type/Atomic/TTypeAlias.php index b7b9d2c2515..09e7987f968 100644 --- a/src/Psalm/Type/Atomic/TTypeAlias.php +++ b/src/Psalm/Type/Atomic/TTypeAlias.php @@ -7,7 +7,7 @@ use function array_map; use function implode; -class TTypeAlias extends Atomic +final class TTypeAlias extends Atomic { /** * @var array|null diff --git a/src/Psalm/Type/Atomic/TValueOfArray.php b/src/Psalm/Type/Atomic/TValueOfArray.php index 7b10f16ee59..e4d1178bf80 100644 --- a/src/Psalm/Type/Atomic/TValueOfArray.php +++ b/src/Psalm/Type/Atomic/TValueOfArray.php @@ -11,7 +11,7 @@ /** * Represents a value of an array. */ -class TValueOfArray extends Atomic +final class TValueOfArray extends Atomic { /** @var Union */ public $type; diff --git a/src/Psalm/Type/Atomic/TVoid.php b/src/Psalm/Type/Atomic/TVoid.php index 4efdd4587c1..f885fe03370 100644 --- a/src/Psalm/Type/Atomic/TVoid.php +++ b/src/Psalm/Type/Atomic/TVoid.php @@ -7,7 +7,7 @@ /** * Denotes the `void` type, normally just used to annotate a function/method that returns nothing */ -class TVoid extends Atomic +final class TVoid extends Atomic { public function getKey(bool $include_extra = true): string { diff --git a/src/Psalm/Type/TaintKind.php b/src/Psalm/Type/TaintKind.php index b5022d98612..ea76b6c90a5 100644 --- a/src/Psalm/Type/TaintKind.php +++ b/src/Psalm/Type/TaintKind.php @@ -5,7 +5,7 @@ /** * An Enum class holding all the taint types that Psalm recognises */ -class TaintKind +final class TaintKind { public const INPUT_CALLABLE = 'callable'; public const INPUT_UNSERIALIZE = 'unserialize'; diff --git a/src/Psalm/Type/TaintKindGroup.php b/src/Psalm/Type/TaintKindGroup.php index de1b365def5..eb74a2916a6 100644 --- a/src/Psalm/Type/TaintKindGroup.php +++ b/src/Psalm/Type/TaintKindGroup.php @@ -5,7 +5,7 @@ /** * An Enum class holding all the taint types that Psalm recognises */ -class TaintKindGroup +final class TaintKindGroup { public const ALL_INPUT = [ TaintKind::INPUT_HTML, diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index a5c550bbf15..0eedd9bf404 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -54,7 +54,7 @@ use function sort; use function strpos; -class Union implements TypeNode +final class Union implements TypeNode { /** * @var non-empty-array From 7c344366a3a02783bcb404ccb1aad3d982d70bbd Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 10 Feb 2022 01:44:50 +0200 Subject: [PATCH 2/3] Fix RedundantCondition --- .../Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php index f35fdc28293..e24f5a3e531 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php @@ -95,7 +95,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if (isset($atomic_type->properties['options']) && $atomic_type->properties['options']->hasArray() - && ($options_array = $atomic_type->properties['options']->getAtomicTypes()['array']) + && ($options_array = $atomic_type->properties['options']->getAtomicTypes()['array'] ?? null) && $options_array instanceof TKeyedArray && isset($options_array->properties['default']) ) { From 69f5ccfdafc791a0f3a5ed0ca144254406555334 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Thu, 10 Feb 2022 01:49:24 +0200 Subject: [PATCH 3/3] Update UPGRADING.md --- UPGRADING.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/UPGRADING.md b/UPGRADING.md index dd0bf4ce58f..b44f1d37cbc 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -723,6 +723,62 @@ - [BC] Class `Psalm\Node\Scalar\VirtualString` became final - [BC] Class `Psalm\Node\Scalar\VirtualEncapsed` became final - [BC] Class `Psalm\Node\VirtualConst` became final + - Type nodes became final + - [BC] Class `Psalm\Type\TaintKindGroup` became final + - [BC] Class `Psalm\Type\Atomic\TNumericString` became final + - [BC] Class `Psalm\Type\Atomic\TClassStringMap` became final + - [BC] Class `Psalm\Type\Atomic\TEmptyNumeric` became final + - [BC] Class `Psalm\Type\Atomic\TCallableObject` became final + - [BC] Class `Psalm\Type\Atomic\TSingleLetter` became final + - [BC] Class `Psalm\Type\Atomic\TClosedResource` became final + - [BC] Class `Psalm\Type\Atomic\TIntMaskOf` became final + - [BC] Class `Psalm\Type\Atomic\TNonEmptyScalar` became final + - [BC] Class `Psalm\Type\Atomic\TLowercaseString` became final + - [BC] Class `Psalm\Type\Atomic\TCallable` became final + - [BC] Class `Psalm\Type\Atomic\TFalse` became final + - [BC] Class `Psalm\Type\Atomic\TIterable` became final + - [BC] Class `Psalm\Type\Atomic\TTraitString` became final + - [BC] Class `Psalm\Type\Atomic\TNonEmptyNonspecificLiteralString` became final + - [BC] Class `Psalm\Type\Atomic\TLiteralInt` became final + - [BC] Class `Psalm\Type\Atomic\TTrue` became final + - [BC] Class `Psalm\Type\Atomic\TDependentGetClass` became final + - [BC] Class `Psalm\Type\Atomic\TValueOfArray` became final + - [BC] Class `Psalm\Type\Atomic\TGenericObject` became final + - [BC] Class `Psalm\Type\Atomic\TNonEmptyLowercaseString` became final + - [BC] Class `Psalm\Type\Atomic\TEnumCase` became final + - [BC] Class `Psalm\Type\Atomic\TCallableKeyedArray` became final + - [BC] Class `Psalm\Type\Atomic\TDependentGetDebugType` became final + - [BC] Class `Psalm\Type\Atomic\TKeyOfArray` became final + - [BC] Class `Psalm\Type\Atomic\TNonspecificLiteralInt` became final + - [BC] Class `Psalm\Type\Atomic\TObjectWithProperties` became final + - [BC] Class `Psalm\Type\Atomic\TTemplateValueOf` became final + - [BC] Class `Psalm\Type\Atomic\TDependentListKey` became final + - [BC] Class `Psalm\Type\Atomic\TConditional` became final + - [BC] Class `Psalm\Type\Atomic\TIntRange` became final + - [BC] Class `Psalm\Type\Atomic\TCallableString` became final + - [BC] Class `Psalm\Type\Atomic\TClosure` became final + - [BC] Class `Psalm\Type\Atomic\TTypeAlias` became final + - [BC] Class `Psalm\Type\Atomic\TAnonymousClassInstance` became final + - [BC] Class `Psalm\Type\Atomic\TIntMask` became final + - [BC] Class `Psalm\Type\Atomic\TTemplateKeyOf` became final + - [BC] Class `Psalm\Type\Atomic\TDependentGetType` became final + - [BC] Class `Psalm\Type\Atomic\TLiteralFloat` became final + - [BC] Class `Psalm\Type\Atomic\TCallableArray` became final + - [BC] Class `Psalm\Type\Atomic\TNonEmptyMixed` became final + - [BC] Class `Psalm\Type\Atomic\TTemplateParamClass` became final + - [BC] Class `Psalm\Type\Atomic\TTemplateIndexedAccess` became final + - [BC] Class `Psalm\Type\Atomic\TEmptyScalar` became final + - [BC] Class `Psalm\Type\Atomic\TNever` became final + - [BC] Class `Psalm\Type\Atomic\TNull` became final + - [BC] Class `Psalm\Type\Atomic\TTemplateParam` became final + - [BC] Class `Psalm\Type\Atomic\TLiteralClassString` became final + - [BC] Class `Psalm\Type\Atomic\TResource` became final + - [BC] Class `Psalm\Type\Atomic\TVoid` became final + - [BC] Class `Psalm\Type\Atomic\TCallableList` became final + - [BC] Class `Psalm\Type\Atomic\TEmptyMixed` became final + - [BC] Class `Psalm\Type\Atomic\TClassConstant` became final + - [BC] Class `Psalm\Type\TaintKind` became final + - [BC] Class `Psalm\Type\Union` became final ## Removed - [BC] Property `Psalm\Codebase::$php_major_version` was removed, use