Skip to content

Commit cca538e

Browse files
committed
Add TemplateCovariant tag
1 parent 19b5535 commit cca538e

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of phpDocumentor.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @link http://phpdoc.org
12+
*/
13+
14+
namespace phpDocumentor\Reflection\DocBlock\Tags;
15+
16+
use phpDocumentor\Reflection\DocBlock\Description;
17+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
18+
use phpDocumentor\Reflection\Type;
19+
use phpDocumentor\Reflection\TypeResolver;
20+
use phpDocumentor\Reflection\Types\Context as TypeContext;
21+
use Webmozart\Assert\Assert;
22+
23+
/**
24+
* Reflection class for a {@}template-covariant tag in a Docblock.
25+
*/
26+
final class TemplateCovariant extends TagWithType implements Factory\StaticMethod
27+
{
28+
public function __construct(Type $type, ?Description $description = null)
29+
{
30+
$this->name = 'template-covariant';
31+
$this->type = $type;
32+
$this->description = $description;
33+
}
34+
35+
public static function create(
36+
string $body,
37+
?TypeResolver $typeResolver = null,
38+
?DescriptionFactory $descriptionFactory = null,
39+
?TypeContext $context = null
40+
): self {
41+
Assert::notNull($typeResolver);
42+
Assert::notNull($descriptionFactory);
43+
44+
[$type, $description] = self::extractTypeFromBody($body);
45+
46+
$type = $typeResolver->resolve($type, $context);
47+
$description = $descriptionFactory->create($description, $context);
48+
49+
return new static($type, $description);
50+
}
51+
}

0 commit comments

Comments
 (0)