Skip to content

Commit

Permalink
Remove needless CallableArrayType and CallableStringType
Browse files Browse the repository at this point in the history
  • Loading branch information
klimick committed Feb 16, 2024
1 parent 33ecb33 commit 84fb6ee
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
10 changes: 0 additions & 10 deletions src/Nullability/NullableChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ public function visitClassString(Type\ClassStringType $type): mixed
return false;
}

public function visitCallableString(Type\CallableStringType $type): mixed
{
return false;
}

public function visitInterfaceString(Type\InterfaceStringType $type): mixed
{
return false;
Expand Down Expand Up @@ -191,11 +186,6 @@ public function visitNonEmptyArray(Type\NonEmptyArrayType $type): mixed
return false;
}

public function visitCallableArray(Type\CallableArrayType $type): mixed
{
return false;
}

public function visitArray(Type\ArrayType $type): mixed
{
return false;
Expand Down
13 changes: 11 additions & 2 deletions src/PhpDocParser/ContextualPhpDocTypeReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,20 @@ private function reflectIdentifier(string $name, array $genericTypes = []): Type
'array-key' => types::arrayKey,
'literal-int' => types::literalInt,
'literal-string' => types::literalString,
'callable-string' => types::callableString,
'callable-string' => types::intersection(
types::literalString,
types::callable(),
),
'interface-string' => types::interfaceString,
'enum-string' => types::enumString,
'trait-string' => types::traitString,
'callable-array' => types::callableArray,
'callable-array' => types::intersection(
types::arrayShape([
types::union(types::classString, types::object),
types::literalString,
]),
types::callable(),
),
'resource' => types::resource,
'closed-resource' => types::closedResource,
'object' => types::object,
Expand Down
10 changes: 0 additions & 10 deletions src/TypeResolver/RecursiveTypeReplacer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ public function visitClassString(Type\ClassStringType $type): mixed
return $type;
}

public function visitCallableString(Type\CallableStringType $type): mixed
{
return $type;
}

public function visitInterfaceString(Type\InterfaceStringType $type): mixed
{
return $type;
Expand Down Expand Up @@ -198,11 +193,6 @@ public function visitNonEmptyArray(Type\NonEmptyArrayType $type): mixed
return types::nonEmptyArray($type->keyType->accept($this), $type->valueType->accept($this));
}

public function visitCallableArray(Type\CallableArrayType $type): mixed
{
return $type;
}

public function visitArray(Type\ArrayType $type): mixed
{
/** @psalm-suppress MixedArgumentTypeCoercion */
Expand Down
13 changes: 11 additions & 2 deletions tests/unit/PhpDocParser/ContextualPhpDocTypeReflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public static function validTypes(): \Generator
yield ['literal-string', types::literalString];
yield ['numeric-string', types::numericString];
yield ['class-string', types::classString];
yield ['callable-string', types::callableString];
yield ['callable-string', types::intersection(
types::literalString,
types::callable(),
)];
yield ['interface-string', types::interfaceString];
yield ['enum-string', types::enumString];
yield ['trait-string', types::traitString];
Expand All @@ -81,7 +84,13 @@ public static function validTypes(): \Generator
yield ['string', types::string];
yield ['numeric', types::numeric];
yield ['scalar', types::scalar];
yield ['callable-array', types::callableArray];
yield ['callable-array', types::intersection(
types::arrayShape([
types::union(types::classString, types::object),
types::literalString,
]),
types::callable(),
)];
yield ['object', types::object];
yield ['resource', types::resource];
yield ['closed-resource', types::closedResource];
Expand Down

0 comments on commit 84fb6ee

Please sign in to comment.