From cca538efed288026ca67d2bf1bc9503ea097bd9d Mon Sep 17 00:00:00 2001 From: AhJ Date: Wed, 24 Jul 2024 12:11:07 +0330 Subject: [PATCH] Add TemplateCovariant tag --- src/DocBlock/Tags/TemplateCovariant.php | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/DocBlock/Tags/TemplateCovariant.php diff --git a/src/DocBlock/Tags/TemplateCovariant.php b/src/DocBlock/Tags/TemplateCovariant.php new file mode 100644 index 0000000..d5d5098 --- /dev/null +++ b/src/DocBlock/Tags/TemplateCovariant.php @@ -0,0 +1,51 @@ +name = 'template-covariant'; + $this->type = $type; + $this->description = $description; + } + + public static function create( + string $body, + ?TypeResolver $typeResolver = null, + ?DescriptionFactory $descriptionFactory = null, + ?TypeContext $context = null + ): self { + Assert::notNull($typeResolver); + Assert::notNull($descriptionFactory); + + [$type, $description] = self::extractTypeFromBody($body); + + $type = $typeResolver->resolve($type, $context); + $description = $descriptionFactory->create($description, $context); + + return new static($type, $description); + } +}