From 62e5cd7f1e4e46aaf9fdd6550e5648c94a7e79d6 Mon Sep 17 00:00:00 2001 From: Andrey K <34217190+klimick@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:22:27 +0300 Subject: [PATCH] Remove needless CallableArrayType and CallableStringType (#30) Since this can be expressed through: - String callable: `callable&string` - Static array method: `callable&list{class-string, string}` - Instance array method: `callable&list{object, string}` Does it make sense to add factory methods for `callable-string` and `callable-array` to the `types` ? These are quite rare types and the chance that someone will ever use these methods is small. --- src/CallableArrayType.php | 24 ------------------------ src/CallableStringType.php | 24 ------------------------ src/TypeVisitor.php | 6 ------ src/types.php | 2 -- tests/PsalmTest.php | 2 -- tests/psalm/CallableArrayType.phpt | 9 --------- tests/psalm/CallableStringType.phpt | 9 --------- 7 files changed, 76 deletions(-) delete mode 100644 src/CallableArrayType.php delete mode 100644 src/CallableStringType.php delete mode 100644 tests/psalm/CallableArrayType.phpt delete mode 100644 tests/psalm/CallableStringType.phpt diff --git a/src/CallableArrayType.php b/src/CallableArrayType.php deleted file mode 100644 index c559253..0000000 --- a/src/CallableArrayType.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -enum CallableArrayType implements Type -{ - /** - * @internal - * @psalm-internal Typhoon\Type - */ - case type; - - public function accept(TypeVisitor $visitor): mixed - { - return $visitor->visitCallableArray($this); - } -} diff --git a/src/CallableStringType.php b/src/CallableStringType.php deleted file mode 100644 index d63c3a7..0000000 --- a/src/CallableStringType.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -enum CallableStringType implements Type -{ - /** - * @internal - * @psalm-internal Typhoon\Type - */ - case type; - - public function accept(TypeVisitor $visitor): mixed - { - return $visitor->visitCallableString($this); - } -} diff --git a/src/TypeVisitor.php b/src/TypeVisitor.php index d9a976e..5478c51 100644 --- a/src/TypeVisitor.php +++ b/src/TypeVisitor.php @@ -71,9 +71,6 @@ public function visitNamedClassString(NamedClassStringType $type): mixed; /** @return TReturn */ public function visitClassString(ClassStringType $type): mixed; - /** @return TReturn */ - public function visitCallableString(CallableStringType $type): mixed; - /** @return TReturn */ public function visitInterfaceString(InterfaceStringType $type): mixed; @@ -113,9 +110,6 @@ public function visitArrayShape(ArrayShapeType $type): mixed; /** @return TReturn */ public function visitNonEmptyArray(NonEmptyArrayType $type): mixed; - /** @return TReturn */ - public function visitCallableArray(CallableArrayType $type): mixed; - /** @return TReturn */ public function visitArray(ArrayType $type): mixed; diff --git a/src/types.php b/src/types.php index 9eddb40..7d67113 100644 --- a/src/types.php +++ b/src/types.php @@ -25,7 +25,6 @@ final class types public const literalString = AnyLiteralStringType::type; public const numericString = NumericStringType::type; public const classString = ClassStringType::type; - public const callableString = CallableStringType::type; public const interfaceString = InterfaceStringType::type; public const enumString = EnumStringType::type; public const traitString = TraitStringType::type; @@ -35,7 +34,6 @@ final class types public const string = StringType::type; public const numeric = NumericType::type; public const scalar = ScalarType::type; - public const callableArray = CallableArrayType::type; public const object = ObjectType::type; public const resource = ResourceType::type; public const closedResource = ClosedResourceType::type; diff --git a/tests/PsalmTest.php b/tests/PsalmTest.php index 82de738..2fee26e 100644 --- a/tests/PsalmTest.php +++ b/tests/PsalmTest.php @@ -30,8 +30,6 @@ public static function extractType(Type $_type): mixed #[TestWith([__DIR__ . '/psalm/ArrayShapeType.phpt'])] #[TestWith([__DIR__ . '/psalm/ArrayType.phpt'])] #[TestWith([__DIR__ . '/psalm/BoolType.phpt'])] - #[TestWith([__DIR__ . '/psalm/CallableArrayType.phpt'])] - #[TestWith([__DIR__ . '/psalm/CallableStringType.phpt'])] #[TestWith([__DIR__ . '/psalm/CallableType.phpt'])] #[TestWith([__DIR__ . '/psalm/ClassConstantType.phpt'])] #[TestWith([__DIR__ . '/psalm/ClassStringLiteralType.phpt'])] diff --git a/tests/psalm/CallableArrayType.phpt b/tests/psalm/CallableArrayType.phpt deleted file mode 100644 index a87d664..0000000 --- a/tests/psalm/CallableArrayType.phpt +++ /dev/null @@ -1,9 +0,0 @@ ---FILE-- -