From fff85f3c08a38110bca6a13d341778bbd79a2108 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sat, 11 Sep 2021 23:38:04 +0200 Subject: [PATCH] CompoundTypeHelper is deprecated --- src/Type/Accessory/AccessoryLiteralStringType.php | 3 +-- src/Type/Accessory/AccessoryNonEmptyStringType.php | 3 +-- src/Type/Accessory/AccessoryNumericStringType.php | 3 +-- src/Type/Accessory/HasOffsetType.php | 3 +-- src/Type/Accessory/NonEmptyArrayType.php | 3 +-- src/Type/ArrayType.php | 2 +- src/Type/CallableType.php | 2 +- src/Type/ClosureType.php | 2 +- src/Type/CompoundTypeHelper.php | 3 +++ src/Type/Generic/TemplateTypeParameterStrategy.php | 3 +-- src/Type/IntegerRangeType.php | 2 +- src/Type/IterableType.php | 2 +- src/Type/JustNullableTypeTrait.php | 2 +- src/Type/NullType.php | 2 +- src/Type/ObjectType.php | 2 +- src/Type/ObjectWithoutClassType.php | 2 +- src/Type/StaticType.php | 2 +- src/Type/StringType.php | 2 +- src/Type/Traits/ConstantScalarTypeTrait.php | 3 +-- src/Type/UnionType.php | 2 +- 20 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/Type/Accessory/AccessoryLiteralStringType.php b/src/Type/Accessory/AccessoryLiteralStringType.php index 0208a69b33..2cbf3134f7 100644 --- a/src/Type/Accessory/AccessoryLiteralStringType.php +++ b/src/Type/Accessory/AccessoryLiteralStringType.php @@ -5,7 +5,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\BooleanType; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\ErrorType; @@ -47,7 +46,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic return TrinaryLogic::createNo(); } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $type->isLiteralString(); diff --git a/src/Type/Accessory/AccessoryNonEmptyStringType.php b/src/Type/Accessory/AccessoryNonEmptyStringType.php index 72f2f4a19e..2e3f599e7e 100644 --- a/src/Type/Accessory/AccessoryNonEmptyStringType.php +++ b/src/Type/Accessory/AccessoryNonEmptyStringType.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\ErrorType; @@ -44,7 +43,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $type->isNonEmptyString(); diff --git a/src/Type/Accessory/AccessoryNumericStringType.php b/src/Type/Accessory/AccessoryNumericStringType.php index da0df04efc..3463615c91 100644 --- a/src/Type/Accessory/AccessoryNumericStringType.php +++ b/src/Type/Accessory/AccessoryNumericStringType.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\Constant\ConstantArrayType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\ErrorType; @@ -44,7 +43,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $type->isNumericString(); diff --git a/src/Type/Accessory/HasOffsetType.php b/src/Type/Accessory/HasOffsetType.php index 4ecdc13cf7..f2f5c41714 100644 --- a/src/Type/Accessory/HasOffsetType.php +++ b/src/Type/Accessory/HasOffsetType.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\ConstantScalarType; use PHPStan\Type\ErrorType; use PHPStan\Type\IntersectionType; @@ -49,7 +48,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $type->isOffsetAccessible() diff --git a/src/Type/Accessory/NonEmptyArrayType.php b/src/Type/Accessory/NonEmptyArrayType.php index 3e85adcc3c..0e255f70f9 100644 --- a/src/Type/Accessory/NonEmptyArrayType.php +++ b/src/Type/Accessory/NonEmptyArrayType.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\Constant\ConstantFloatType; use PHPStan\Type\Constant\ConstantIntegerType; use PHPStan\Type\ErrorType; @@ -40,7 +39,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $type->isArray() diff --git a/src/Type/ArrayType.php b/src/Type/ArrayType.php index 73334e6c34..34080be9d9 100644 --- a/src/Type/ArrayType.php +++ b/src/Type/ArrayType.php @@ -66,7 +66,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } if ($type instanceof ConstantArrayType) { diff --git a/src/Type/CallableType.php b/src/Type/CallableType.php index 6a8a1458ff..397c8c6027 100644 --- a/src/Type/CallableType.php +++ b/src/Type/CallableType.php @@ -71,7 +71,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType && !$type instanceof self) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return $this->isSuperTypeOfInternal($type, true); diff --git a/src/Type/ClosureType.php b/src/Type/ClosureType.php index c16a2845fd..6fdf33fd2a 100644 --- a/src/Type/ClosureType.php +++ b/src/Type/ClosureType.php @@ -89,7 +89,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } if (!$type instanceof ClosureType) { diff --git a/src/Type/CompoundTypeHelper.php b/src/Type/CompoundTypeHelper.php index a86e36eb5e..01686a722d 100644 --- a/src/Type/CompoundTypeHelper.php +++ b/src/Type/CompoundTypeHelper.php @@ -4,6 +4,9 @@ use PHPStan\TrinaryLogic; +/** + * @deprecated + */ class CompoundTypeHelper { diff --git a/src/Type/Generic/TemplateTypeParameterStrategy.php b/src/Type/Generic/TemplateTypeParameterStrategy.php index 89e69d6051..5d9a8256d6 100644 --- a/src/Type/Generic/TemplateTypeParameterStrategy.php +++ b/src/Type/Generic/TemplateTypeParameterStrategy.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\Type; /** @@ -16,7 +15,7 @@ class TemplateTypeParameterStrategy implements TemplateTypeStrategy public function accepts(TemplateType $left, Type $right, bool $strictTypes): TrinaryLogic { if ($right instanceof CompoundType) { - return CompoundTypeHelper::accepts($right, $left, $strictTypes); + return $right->isAcceptedBy($left, $strictTypes); } return $left->getBound()->accepts($right, $strictTypes); diff --git a/src/Type/IntegerRangeType.php b/src/Type/IntegerRangeType.php index fc686d5e94..f06302e833 100644 --- a/src/Type/IntegerRangeType.php +++ b/src/Type/IntegerRangeType.php @@ -202,7 +202,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createNo(); diff --git a/src/Type/IterableType.php b/src/Type/IterableType.php index b69dfb2f89..46c21dad4b 100644 --- a/src/Type/IterableType.php +++ b/src/Type/IterableType.php @@ -70,7 +70,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createNo(); diff --git a/src/Type/JustNullableTypeTrait.php b/src/Type/JustNullableTypeTrait.php index 1bd0f92005..703c5b4c66 100644 --- a/src/Type/JustNullableTypeTrait.php +++ b/src/Type/JustNullableTypeTrait.php @@ -22,7 +22,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createNo(); diff --git a/src/Type/NullType.php b/src/Type/NullType.php index b027a1d93f..a4ca1e92c7 100644 --- a/src/Type/NullType.php +++ b/src/Type/NullType.php @@ -57,7 +57,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createNo(); diff --git a/src/Type/ObjectType.php b/src/Type/ObjectType.php index 545048e693..81baf4d731 100644 --- a/src/Type/ObjectType.php +++ b/src/Type/ObjectType.php @@ -204,7 +204,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } if ($type instanceof ClosureType) { diff --git a/src/Type/ObjectWithoutClassType.php b/src/Type/ObjectWithoutClassType.php index bca31f1660..23984955a3 100644 --- a/src/Type/ObjectWithoutClassType.php +++ b/src/Type/ObjectWithoutClassType.php @@ -40,7 +40,7 @@ public function getReferencedClasses(): array public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createFromBoolean( diff --git a/src/Type/StaticType.php b/src/Type/StaticType.php index 6d628a36bf..8326b3a79e 100644 --- a/src/Type/StaticType.php +++ b/src/Type/StaticType.php @@ -110,7 +110,7 @@ public function getBaseClass(): string public function accepts(Type $type, bool $strictTypes): TrinaryLogic { if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } if (!$type instanceof static) { diff --git a/src/Type/StringType.php b/src/Type/StringType.php index 50240f5da6..f94ca86351 100644 --- a/src/Type/StringType.php +++ b/src/Type/StringType.php @@ -79,7 +79,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } if ($type instanceof TypeWithClassName && !$strictTypes) { diff --git a/src/Type/Traits/ConstantScalarTypeTrait.php b/src/Type/Traits/ConstantScalarTypeTrait.php index 0ac64800cd..d21d4882cc 100644 --- a/src/Type/Traits/ConstantScalarTypeTrait.php +++ b/src/Type/Traits/ConstantScalarTypeTrait.php @@ -4,7 +4,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\CompoundType; -use PHPStan\Type\CompoundTypeHelper; use PHPStan\Type\ConstantScalarType; use PHPStan\Type\GeneralizePrecision; use PHPStan\Type\Type; @@ -19,7 +18,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } return TrinaryLogic::createNo(); diff --git a/src/Type/UnionType.php b/src/Type/UnionType.php index d24baf3bbc..08d347c9d9 100644 --- a/src/Type/UnionType.php +++ b/src/Type/UnionType.php @@ -85,7 +85,7 @@ public function accepts(Type $type, bool $strictTypes): TrinaryLogic } if ($type instanceof CompoundType && !$type instanceof CallableType) { - return CompoundTypeHelper::accepts($type, $this, $strictTypes); + return $type->isAcceptedBy($this, $strictTypes); } $results = [];