Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finalize types nodes #7623

Merged
merged 3 commits into from Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 56 additions & 0 deletions UPGRADING.md
Expand Up @@ -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
Expand Down
Expand Up @@ -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'])
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TAnonymousClassInstance.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallable.php
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallableArray.php
Expand Up @@ -5,7 +5,7 @@
/**
* Denotes an array that is _also_ `callable`.
*/
class TCallableArray extends TNonEmptyArray
final class TCallableArray extends TNonEmptyArray
{
/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallableKeyedArray.php
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallableList.php
Expand Up @@ -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';
}
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallableObject.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TCallableString.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TClassConstant.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TClassStringMap.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TClosedResource.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TClosure.php
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TConditional.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TDependentGetClass.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TDependentGetDebugType.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TDependentGetType.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TDependentListKey.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TEmptyMixed.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TEmptyNumeric.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TEmptyScalar.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TEnumCase.php
Expand Up @@ -5,7 +5,7 @@
/**
* Denotes an enum with a specific value
*/
class TEnumCase extends TNamedObject
final class TEnumCase extends TNamedObject
{
/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TFalse.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TGenericObject.php
Expand Up @@ -14,7 +14,7 @@
/**
* Denotes an object type that has generic parameters e.g. `ArrayObject<string, Foo\Bar>`
*/
class TGenericObject extends TNamedObject
final class TGenericObject extends TNamedObject
{
use GenericTrait;

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TIntMask.php
Expand Up @@ -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<TLiteralInt|TClassConstant> */
public $values;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TIntMaskOf.php
Expand Up @@ -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<MyClass::CLASS_CONSTANT_*>` 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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TIntRange.php
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TIterable.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TKeyOfArray.php
Expand Up @@ -11,7 +11,7 @@
/**
* Represents an offset of an array.
*/
class TKeyOfArray extends TArrayKey
final class TKeyOfArray extends TArrayKey
{
/** @var Union */
public $type;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TLiteralClassString.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TLiteralFloat.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TLiteralInt.php
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TLowercaseString.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TNever.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TNonEmptyLowercaseString.php
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TNonEmptyMixed.php
Expand Up @@ -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
{
Expand Down
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic/TNonEmptyScalar.php
Expand Up @@ -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
{
Expand Down