Page MenuHomeWickedGov Phorge

TemplateImplementsFactory.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

TemplateImplementsFactory.php

<?php
declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tags\TemplateImplements;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Webmozart\Assert\Assert;
use function is_string;
/**
* @internal This class is not part of the BC promise of this library.
*/
final class TemplateImplementsFactory implements PHPStanFactory
{
private DescriptionFactory $descriptionFactory;
private TypeResolver $typeResolver;
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
{
$this->descriptionFactory = $descriptionFactory;
$this->typeResolver = $typeResolver;
}
public function supports(PhpDocTagNode $node, Context $context): bool
{
return $node->value instanceof ImplementsTagValueNode && $node->name === '@template-implements';
}
public function create(PhpDocTagNode $node, Context $context): Tag
{
$tagValue = $node->value;
Assert::isInstanceOf($tagValue, ImplementsTagValueNode::class);
$description = $tagValue->getAttribute('description');
if (is_string($description) === false) {
$description = $tagValue->description;
}
return new TemplateImplements(
$this->typeResolver->createType($tagValue->type, $context),
$this->descriptionFactory->create($description, $context)
);
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Nov 23, 01:45 (2 d, 18 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b7/6e/99c6a7ae2d3a170a4f6433b8f8a2
Default Alt Text
TemplateImplementsFactory.php (1 KB)

Event Timeline