diff --git a/extension.neon b/extension.neon index cae132d..7f0a079 100644 --- a/extension.neon +++ b/extension.neon @@ -1,9 +1,4 @@ services: - - - class: JanGregor\Prophecy\PhpDoc\ObjectProphecy\TypeNodeResolverExtension - tags: - - phpstan.phpDoc.typeNodeResolverExtension - - class: JanGregor\Prophecy\Reflection\ObjectProphecy\MethodsClassReflectionExtension tags: diff --git a/src/PhpDoc/ObjectProphecy/TypeNodeResolverExtension.php b/src/PhpDoc/ObjectProphecy/TypeNodeResolverExtension.php deleted file mode 100644 index 47c1675..0000000 --- a/src/PhpDoc/ObjectProphecy/TypeNodeResolverExtension.php +++ /dev/null @@ -1,75 +0,0 @@ -typeNodeResolver = $typeNodeResolver; - } - - public function getCacheKey(): string - { - return 'prophecy-with-generics-v2'; - } - - public function resolve(PhpDocParser\Ast\Type\TypeNode $typeNode, Analyser\NameScope $nameScope): ?Type\Type - { - if (!$typeNode instanceof PhpDocParser\Ast\Type\UnionTypeNode) { - return null; - } - - if (2 === \count($typeNode->types)) { - $objectProphecyType = null; - $prophesizedType = null; - - foreach ($typeNode->types as $innerType) { - $type = $this->typeNodeResolver->resolve($innerType, $nameScope); - - if ($type->isObject()->yes()) { - if ((new Type\ObjectType(Prophecy\ObjectProphecy::class))->isSuperTypeOf($type)->yes()) { - $objectProphecyType = $type; - } else { - $prophesizedType = $type; - } - } else { - break; - } - } - - if (null !== $objectProphecyType && null !== $prophesizedType) { - return new Type\Generic\GenericObjectType( - Prophecy\ObjectProphecy::class, - [ - $prophesizedType, - ], - ); - } - } - - return null; - } -}