mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Fix code style issues
This commit is contained in:
@@ -13,47 +13,47 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock;
|
namespace phpDocumentor\Reflection\DocBlock;
|
||||||
|
|
||||||
use function trim;
|
use InvalidArgumentException;
|
||||||
use function count;
|
use phpDocumentor\Reflection\DocBlock\Tags\Author;
|
||||||
use function strpos;
|
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
|
||||||
use function sprintf;
|
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 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 get_class;
|
||||||
use function is_object;
|
use function is_object;
|
||||||
use function preg_match;
|
use function preg_match;
|
||||||
use ReflectionNamedType;
|
use function sprintf;
|
||||||
use ReflectionParameter;
|
use function strpos;
|
||||||
use function array_merge;
|
use function trim;
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Tag object given the contents of a tag.
|
* Creates a Tag object given the contents of a tag.
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
use Doctrine\Deprecations\Deprecation;
|
use Doctrine\Deprecations\Deprecation;
|
||||||
use phpDocumentor\Reflection\Type;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
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.
|
* Reflection class for a {@}extends tag in a Docblock.
|
||||||
@@ -34,7 +34,7 @@ class Extends_ extends TagWithType
|
|||||||
* @deprecated Create using static factory is deprecated,
|
* @deprecated Create using static factory is deprecated,
|
||||||
* this method should not be called directly by library consumers
|
* 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(
|
Deprecation::trigger(
|
||||||
'phpdocumentor/reflection-docblock',
|
'phpdocumentor/reflection-docblock',
|
||||||
@@ -42,6 +42,7 @@ class Extends_ extends TagWithType
|
|||||||
'Create using static factory is deprecated, this method should not be called directly
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
by library consumers',
|
by library consumers',
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
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;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
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\ImplementsTagValueNode;
|
||||||
|
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal This class is not part of the BC promise of this library.
|
* @internal This class is not part of the BC promise of this library.
|
||||||
*/
|
*/
|
||||||
abstract class AbstractImplementsFactory implements PHPStanFactory
|
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;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
|
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
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.
|
* @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)
|
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($typeResolver, $descriptionFactory);
|
$this->descriptionFactory = $descriptionFactory;
|
||||||
$this->tagName = '@extends';
|
$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
|
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||||
|
|||||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
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\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.
|
* @internal This class is not part of the BC promise of this library.
|
||||||
*/
|
*/
|
||||||
final class ImplementsFactory extends AbstractImplementsFactory
|
final class ImplementsFactory extends AbstractImplementsFactory
|
||||||
{
|
{
|
||||||
|
private DescriptionFactory $descriptionFactory;
|
||||||
|
private TypeResolver $typeResolver;
|
||||||
|
|
||||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($typeResolver, $descriptionFactory);
|
$this->descriptionFactory = $descriptionFactory;
|
||||||
$this->tagName = '@implements';
|
$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
|
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||||
|
|||||||
@@ -4,24 +4,34 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
|
use function is_string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal This class is not part of the BC promise of this library.
|
* @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)
|
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($typeResolver, $descriptionFactory);
|
$this->descriptionFactory = $descriptionFactory;
|
||||||
$this->tagName = '@template-extends';
|
$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
|
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Template;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Template;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
|
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.
|
* @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
|
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||||
{
|
{
|
||||||
$tagValue = $node->value;
|
$tagValue = $node->value;
|
||||||
|
|
||||||
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
|
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
|
||||||
|
$name = $tagValue->name;
|
||||||
|
if ($name === '') {
|
||||||
|
throw new \InvalidArgumentException('Template name cannot be empty');
|
||||||
|
}
|
||||||
|
|
||||||
$description = $tagValue->getAttribute('description');
|
$description = $tagValue->getAttribute('description');
|
||||||
if (is_string($description) === false) {
|
if (is_string($description) === false) {
|
||||||
@@ -38,7 +45,7 @@ final class TemplateFactory implements PHPStanFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Template(
|
return new Template(
|
||||||
$tagValue->name,
|
$name,
|
||||||
$this->typeResolver->createType($tagValue->bound, $context),
|
$this->typeResolver->createType($tagValue->bound, $context),
|
||||||
$this->typeResolver->createType($tagValue->default, $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;
|
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
|
||||||
|
|
||||||
use Webmozart\Assert\Assert;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\TemplateImplements;
|
||||||
use phpDocumentor\Reflection\TypeResolver;
|
use phpDocumentor\Reflection\TypeResolver;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
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\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.
|
* @internal This class is not part of the BC promise of this library.
|
||||||
*/
|
*/
|
||||||
final class TemplateImplementsFactory extends AbstractImplementsFactory
|
final class TemplateImplementsFactory extends AbstractImplementsFactory
|
||||||
{
|
{
|
||||||
|
private DescriptionFactory $descriptionFactory;
|
||||||
|
private TypeResolver $typeResolver;
|
||||||
|
|
||||||
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
|
||||||
{
|
{
|
||||||
parent::__construct($typeResolver, $descriptionFactory);
|
$this->descriptionFactory = $descriptionFactory;
|
||||||
$this->tagName = '@template-implements';
|
$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
|
public function create(PhpDocTagNode $node, Context $context): Tag
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
use Doctrine\Deprecations\Deprecation;
|
use Doctrine\Deprecations\Deprecation;
|
||||||
use phpDocumentor\Reflection\Type;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
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.
|
* Reflection class for a {@}implements tag in a Docblock.
|
||||||
@@ -34,7 +34,7 @@ class Implements_ extends TagWithType
|
|||||||
* @deprecated Create using static factory is deprecated,
|
* @deprecated Create using static factory is deprecated,
|
||||||
* this method should not be called directly by library consumers
|
* 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(
|
Deprecation::trigger(
|
||||||
'phpdocumentor/reflection-docblock',
|
'phpdocumentor/reflection-docblock',
|
||||||
@@ -42,6 +42,7 @@ class Implements_ extends TagWithType
|
|||||||
'Create using static factory is deprecated, this method should not be called directly
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
by library consumers',
|
by library consumers',
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ declare(strict_types=1);
|
|||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
use Doctrine\Deprecations\Deprecation;
|
use Doctrine\Deprecations\Deprecation;
|
||||||
use phpDocumentor\Reflection\Type;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
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.
|
* Reflection class for a {@}template tag in a Docblock.
|
||||||
@@ -24,16 +24,20 @@ use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
|
|||||||
final class Template extends TagWithType
|
final class Template extends TagWithType
|
||||||
{
|
{
|
||||||
/** @var non-empty-string */
|
/** @var non-empty-string */
|
||||||
private $templateName;
|
private string $templateName;
|
||||||
|
|
||||||
/** @var ?Type The real type */
|
/** @var ?Type The real type */
|
||||||
private $bound;
|
private ?Type $bound;
|
||||||
|
|
||||||
/** @var ?Type */
|
private ?Type $default;
|
||||||
private $default;
|
|
||||||
|
|
||||||
public function __construct(string $templateName, ?Type $bound = null, ?Type $default = null, ?Description $description = null)
|
/** @param non-empty-string $templateName */
|
||||||
{
|
public function __construct(
|
||||||
|
string $templateName,
|
||||||
|
?Type $bound = null,
|
||||||
|
?Type $default = null,
|
||||||
|
?Description $description = null
|
||||||
|
) {
|
||||||
$this->name = 'template';
|
$this->name = 'template';
|
||||||
$this->templateName = $templateName;
|
$this->templateName = $templateName;
|
||||||
$this->bound = $bound;
|
$this->bound = $bound;
|
||||||
@@ -45,7 +49,7 @@ final class Template extends TagWithType
|
|||||||
* @deprecated Create using static factory is deprecated,
|
* @deprecated Create using static factory is deprecated,
|
||||||
* this method should not be called directly by library consumers
|
* 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(
|
Deprecation::trigger(
|
||||||
'phpdocumentor/reflection-docblock',
|
'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
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
by library consumers',
|
by library consumers',
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +78,8 @@ final class Template extends TagWithType
|
|||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
$bound = $this->bound !== null ? " of {$this->bound}" : '';
|
$bound = $this->bound !== null ? ' of ' . $this->bound : '';
|
||||||
$default = $this->default !== null ? " = {$this->default}" : '';
|
$default = $this->default !== null ? ' = ' . $this->default : '';
|
||||||
|
|
||||||
if ($this->description) {
|
if ($this->description) {
|
||||||
$description = $this->description->render();
|
$description = $this->description->render();
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\Type;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
|
use phpDocumentor\Reflection\Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@}template-extends tag in a Docblock.
|
* Reflection class for a {@}template-extends tag in a Docblock.
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||||
|
|
||||||
use phpDocumentor\Reflection\Type;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Description;
|
use phpDocumentor\Reflection\DocBlock\Description;
|
||||||
|
use phpDocumentor\Reflection\Type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reflection class for a {@}template-implements tag in a Docblock.
|
* Reflection class for a {@}template-implements tag in a Docblock.
|
||||||
|
|||||||
+19
-19
@@ -13,39 +13,39 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace phpDocumentor\Reflection;
|
namespace phpDocumentor\Reflection;
|
||||||
|
|
||||||
use LogicException;
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Webmozart\Assert\Assert;
|
use LogicException;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tag;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
use phpDocumentor\Reflection\DocBlock\TagFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ExtendsFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ExtendsFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateFactory;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ImplementsFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateExtendsFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateExtendsFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateImplementsFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TemplateImplementsFactory;
|
||||||
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
||||||
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
use function trim;
|
use function array_shift;
|
||||||
use function count;
|
use function count;
|
||||||
use function strpos;
|
|
||||||
use function substr;
|
|
||||||
use function explode;
|
use function explode;
|
||||||
use function is_object;
|
use function is_object;
|
||||||
use function preg_match;
|
|
||||||
use function array_shift;
|
|
||||||
use function str_replace;
|
|
||||||
use function preg_replace;
|
|
||||||
use function method_exists;
|
use function method_exists;
|
||||||
|
use function preg_match;
|
||||||
|
use function preg_replace;
|
||||||
|
use function str_replace;
|
||||||
|
use function strpos;
|
||||||
|
use function substr;
|
||||||
|
use function trim;
|
||||||
|
|
||||||
final class DocBlockFactory implements DocBlockFactoryInterface
|
final class DocBlockFactory implements DocBlockFactoryInterface
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user