mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Fix code style issues
This commit is contained in:
@@ -13,47 +13,47 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
use function trim;
|
||||
use function count;
|
||||
use function strpos;
|
||||
use function sprintf;
|
||||
use InvalidArgumentException;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Property;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Since;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Source;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Version;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use ReflectionMethod;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function array_slice;
|
||||
use function call_user_func_array;
|
||||
use function count;
|
||||
use function get_class;
|
||||
use function is_object;
|
||||
use function preg_match;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionParameter;
|
||||
use function array_merge;
|
||||
use function array_slice;
|
||||
use Webmozart\Assert\Assert;
|
||||
use InvalidArgumentException;
|
||||
use function array_key_exists;
|
||||
use function call_user_func_array;
|
||||
use phpDocumentor\Reflection\FqsenResolver;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Param;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Since;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Source;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Version;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Property;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
|
||||
use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
|
||||
use function sprintf;
|
||||
use function strpos;
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Creates a Tag object given the contents of a tag.
|
||||
|
||||
@@ -14,14 +14,14 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}extends tag in a Docblock.
|
||||
*/
|
||||
class Extends_ extends TagWithType
|
||||
class Extends_ extends TagWithType
|
||||
{
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ class Extends_ extends TagWithType
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(string $body)
|
||||
public static function create(string $body): ?Tag
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
@@ -42,6 +42,7 @@ class Extends_ extends TagWithType
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
|
||||
/**
|
||||
* @internal This class is not part of the BC promise of this library.
|
||||
*/
|
||||
abstract class AbstractExtendsFactory implements PHPStanFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
protected string $tagName;
|
||||
|
||||
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 ExtendsTagValueNode && $node->name === $this->tagName;
|
||||
}
|
||||
}
|
||||
@@ -4,29 +4,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
|
||||
/**
|
||||
* @internal This class is not part of the BC promise of this library.
|
||||
*/
|
||||
abstract class AbstractImplementsFactory implements PHPStanFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
protected string $tagName;
|
||||
|
||||
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 === $this->tagName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
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 ExtendsFactory extends AbstractExtendsFactory
|
||||
final class ExtendsFactory implements PHPStanFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
|
||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||
{
|
||||
parent::__construct($typeResolver, $descriptionFactory);
|
||||
$this->tagName = '@extends';
|
||||
$this->descriptionFactory = $descriptionFactory;
|
||||
$this->typeResolver = $typeResolver;
|
||||
}
|
||||
|
||||
public function supports(PhpDocTagNode $node, Context $context): bool
|
||||
{
|
||||
return $node->value instanceof ExtendsTagValueNode && $node->name === '@extends';
|
||||
}
|
||||
|
||||
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||
@@ -36,7 +46,7 @@ final class ExtendsFactory extends AbstractExtendsFactory
|
||||
|
||||
return new Extends_(
|
||||
$this->typeResolver->createType($tagValue->type, $context),
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
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 ImplementsFactory extends AbstractImplementsFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
|
||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||
{
|
||||
parent::__construct($typeResolver, $descriptionFactory);
|
||||
$this->tagName = '@implements';
|
||||
$this->descriptionFactory = $descriptionFactory;
|
||||
$this->typeResolver = $typeResolver;
|
||||
}
|
||||
|
||||
public function supports(PhpDocTagNode $node, Context $context): bool
|
||||
{
|
||||
return $node->value instanceof ImplementsTagValueNode && $node->name === '@implements';
|
||||
}
|
||||
|
||||
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||
@@ -36,7 +46,7 @@ final class ImplementsFactory extends AbstractImplementsFactory
|
||||
|
||||
return new Implements_(
|
||||
$this->typeResolver->createType($tagValue->type, $context),
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
|
||||
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 TemplateExtendsFactory extends AbstractExtendsFactory
|
||||
final class TemplateExtendsFactory implements PHPStanFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
|
||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||
{
|
||||
parent::__construct($typeResolver, $descriptionFactory);
|
||||
$this->tagName = '@template-extends';
|
||||
$this->descriptionFactory = $descriptionFactory;
|
||||
$this->typeResolver = $typeResolver;
|
||||
}
|
||||
|
||||
public function supports(PhpDocTagNode $node, Context $context): bool
|
||||
{
|
||||
return $node->value instanceof ExtendsTagValueNode && $node->name === '@template-extends';
|
||||
}
|
||||
|
||||
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||
@@ -36,7 +46,7 @@ final class TemplateExtendsFactory extends AbstractExtendsFactory
|
||||
|
||||
return new TemplateExtends(
|
||||
$this->typeResolver->createType($tagValue->type, $context),
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Template;
|
||||
use phpDocumentor\Reflection\TypeResolver;
|
||||
use phpDocumentor\Reflection\Types\Context;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\Template;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* @internal This class is not part of the BC promise of this library.
|
||||
@@ -30,7 +32,12 @@ final class TemplateFactory implements PHPStanFactory
|
||||
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||
{
|
||||
$tagValue = $node->value;
|
||||
|
||||
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
|
||||
$name = $tagValue->name;
|
||||
if ($name === '') {
|
||||
throw new \InvalidArgumentException('Template name cannot be empty');
|
||||
}
|
||||
|
||||
$description = $tagValue->getAttribute('description');
|
||||
if (is_string($description) === false) {
|
||||
@@ -38,10 +45,10 @@ final class TemplateFactory implements PHPStanFactory
|
||||
}
|
||||
|
||||
return new Template(
|
||||
$tagValue->name,
|
||||
$name,
|
||||
$this->typeResolver->createType($tagValue->bound, $context),
|
||||
$this->typeResolver->createType($tagValue->default, $context),
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||
|
||||
use Webmozart\Assert\Assert;
|
||||
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\PhpDocTagNode;
|
||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateImplements;
|
||||
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 extends AbstractImplementsFactory
|
||||
{
|
||||
private DescriptionFactory $descriptionFactory;
|
||||
private TypeResolver $typeResolver;
|
||||
|
||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||
{
|
||||
parent::__construct($typeResolver, $descriptionFactory);
|
||||
$this->tagName = '@template-implements';
|
||||
$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
|
||||
@@ -36,7 +46,7 @@ final class TemplateImplementsFactory extends AbstractImplementsFactory
|
||||
|
||||
return new TemplateImplements(
|
||||
$this->typeResolver->createType($tagValue->type, $context),
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
$this->descriptionFactory->create($description, $context)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}implements tag in a Docblock.
|
||||
*/
|
||||
class Implements_ extends TagWithType
|
||||
class Implements_ extends TagWithType
|
||||
{
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ class Implements_ extends TagWithType
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(string $body)
|
||||
public static function create(string $body): ?Tag
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
@@ -42,6 +42,7 @@ class Implements_ extends TagWithType
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,38 +14,42 @@ declare(strict_types=1);
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}template tag in a Docblock.
|
||||
*/
|
||||
final class Template extends TagWithType
|
||||
final class Template extends TagWithType
|
||||
{
|
||||
/** @var non-empty-string */
|
||||
private $templateName;
|
||||
/** @var non-empty-string */
|
||||
private string $templateName;
|
||||
|
||||
/** @var ?Type The real type */
|
||||
private $bound;
|
||||
/** @var ?Type The real type */
|
||||
private ?Type $bound;
|
||||
|
||||
/** @var ?Type */
|
||||
private $default;
|
||||
private ?Type $default;
|
||||
|
||||
public function __construct(string $templateName, ?Type $bound = null, ?Type $default = null, ?Description $description = null)
|
||||
{
|
||||
$this->name = 'template';
|
||||
/** @param non-empty-string $templateName */
|
||||
public function __construct(
|
||||
string $templateName,
|
||||
?Type $bound = null,
|
||||
?Type $default = null,
|
||||
?Description $description = null
|
||||
) {
|
||||
$this->name = 'template';
|
||||
$this->templateName = $templateName;
|
||||
$this->bound = $bound;
|
||||
$this->default = $default;
|
||||
$this->description = $description;
|
||||
$this->bound = $bound;
|
||||
$this->default = $default;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(string $body)
|
||||
public static function create(string $body): ?Tag
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'phpdocumentor/reflection-docblock',
|
||||
@@ -53,6 +57,7 @@ final class Template extends TagWithType
|
||||
'Create using static factory is deprecated, this method should not be called directly
|
||||
by library consumers',
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -73,8 +78,8 @@ final class Template extends TagWithType
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$bound = $this->bound !== null ? " of {$this->bound}" : '';
|
||||
$default = $this->default !== null ? " = {$this->default}" : '';
|
||||
$bound = $this->bound !== null ? ' of ' . $this->bound : '';
|
||||
$default = $this->default !== null ? ' = ' . $this->default : '';
|
||||
|
||||
if ($this->description) {
|
||||
$description = $this->description->render();
|
||||
|
||||
@@ -13,13 +13,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}template-extends tag in a Docblock.
|
||||
*/
|
||||
final class TemplateExtends extends Extends_
|
||||
final class TemplateExtends extends Extends_
|
||||
{
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
|
||||
@@ -13,13 +13,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
|
||||
use phpDocumentor\Reflection\Type;
|
||||
use phpDocumentor\Reflection\DocBlock\Description;
|
||||
use phpDocumentor\Reflection\Type;
|
||||
|
||||
/**
|
||||
* Reflection class for a {@}template-implements tag in a Docblock.
|
||||
*/
|
||||
final class TemplateImplements extends Implements_
|
||||
final class TemplateImplements extends Implements_
|
||||
{
|
||||
public function __construct(Type $type, ?Description $description = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user