Skip to content

Commit 06e5db2

Browse files
committed
Fix code style issues
1 parent bd5b5a8 commit 06e5db2

14 files changed

+170
-161
lines changed

src/DocBlock/StandardTagFactory.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,47 @@
1313

1414
namespace phpDocumentor\Reflection\DocBlock;
1515

16-
use function trim;
17-
use function count;
18-
use function strpos;
19-
use function sprintf;
20-
use ReflectionMethod;
21-
use function get_class;
22-
use function is_object;
23-
use function preg_match;
24-
use ReflectionNamedType;
25-
use ReflectionParameter;
26-
use function array_merge;
27-
use function array_slice;
28-
use Webmozart\Assert\Assert;
2916
use InvalidArgumentException;
30-
use function array_key_exists;
31-
use function call_user_func_array;
32-
use phpDocumentor\Reflection\FqsenResolver;
33-
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
34-
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
35-
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
36-
use phpDocumentor\Reflection\DocBlock\Tags\Param;
37-
use phpDocumentor\Reflection\DocBlock\Tags\Since;
3817
use phpDocumentor\Reflection\DocBlock\Tags\Author;
3918
use phpDocumentor\Reflection\DocBlock\Tags\Covers;
40-
use phpDocumentor\Reflection\DocBlock\Tags\Method;
41-
use phpDocumentor\Reflection\DocBlock\Tags\Source;
42-
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
43-
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
44-
45-
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
46-
use phpDocumentor\Reflection\DocBlock\Tags\Version;
47-
use phpDocumentor\Reflection\DocBlock\Tags\Property;
4819
use phpDocumentor\Reflection\DocBlock\Tags\Deprecated;
20+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
21+
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
4922
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
23+
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
24+
use phpDocumentor\Reflection\DocBlock\Tags\Method;
25+
use phpDocumentor\Reflection\DocBlock\Tags\Mixin;
26+
use phpDocumentor\Reflection\DocBlock\Tags\Param;
27+
use phpDocumentor\Reflection\DocBlock\Tags\Property;
5028
use phpDocumentor\Reflection\DocBlock\Tags\PropertyRead;
5129
use phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite;
30+
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
5231
use phpDocumentor\Reflection\DocBlock\Tags\See as SeeTag;
53-
use phpDocumentor\Reflection\Types\Context as TypeContext;
54-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
55-
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
32+
use phpDocumentor\Reflection\DocBlock\Tags\Since;
33+
use phpDocumentor\Reflection\DocBlock\Tags\Source;
5634
use phpDocumentor\Reflection\DocBlock\Tags\TemplateCovariant;
35+
use phpDocumentor\Reflection\DocBlock\Tags\Throws;
36+
use phpDocumentor\Reflection\DocBlock\Tags\Uses;
37+
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
38+
use phpDocumentor\Reflection\DocBlock\Tags\Version;
39+
use phpDocumentor\Reflection\FqsenResolver;
40+
use phpDocumentor\Reflection\Types\Context as TypeContext;
41+
use ReflectionMethod;
42+
use ReflectionNamedType;
43+
use ReflectionParameter;
44+
use Webmozart\Assert\Assert;
45+
46+
use function array_key_exists;
47+
use function array_merge;
48+
use function array_slice;
49+
use function call_user_func_array;
50+
use function count;
51+
use function get_class;
52+
use function is_object;
53+
use function preg_match;
54+
use function sprintf;
55+
use function strpos;
56+
use function trim;
5757

5858
/**
5959
* Creates a Tag object given the contents of a tag.

src/DocBlock/Tags/Extends_.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
namespace phpDocumentor\Reflection\DocBlock\Tags;
1515

1616
use Doctrine\Deprecations\Deprecation;
17-
use phpDocumentor\Reflection\Type;
1817
use phpDocumentor\Reflection\DocBlock\Description;
19-
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType;
18+
use phpDocumentor\Reflection\DocBlock\Tag;
19+
use phpDocumentor\Reflection\Type;
2020

2121
/**
2222
* Reflection class for a {@}extends tag in a Docblock.
2323
*/
24-
class Extends_ extends TagWithType
24+
class Extends_ extends TagWithType
2525
{
2626
public function __construct(Type $type, ?Description $description = null)
2727
{
@@ -34,14 +34,15 @@ public function __construct(Type $type, ?Description $description = null)
3434
* @deprecated Create using static factory is deprecated,
3535
* this method should not be called directly by library consumers
3636
*/
37-
public static function create(string $body)
37+
public static function create(string $body): ?Tag
3838
{
3939
Deprecation::trigger(
4040
'phpdocumentor/reflection-docblock',
4141
'https://github.com/phpDocumentor/ReflectionDocBlock/issues/361',
4242
'Create using static factory is deprecated, this method should not be called directly
4343
by library consumers',
4444
);
45+
4546
return null;
4647
}
4748
}

src/DocBlock/Tags/Factory/AbstractExtendsFactory.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/DocBlock/Tags/Factory/AbstractImplementsFactory.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,16 @@
44

55
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
66

7+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
78
use phpDocumentor\Reflection\TypeResolver;
89
use phpDocumentor\Reflection\Types\Context;
9-
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
10-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
1110
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
11+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
1212

1313
/**
1414
* @internal This class is not part of the BC promise of this library.
1515
*/
1616
abstract class AbstractImplementsFactory implements PHPStanFactory
1717
{
18-
private DescriptionFactory $descriptionFactory;
19-
private TypeResolver $typeResolver;
20-
protected string $tagName;
21-
22-
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
23-
{
24-
$this->descriptionFactory = $descriptionFactory;
25-
$this->typeResolver = $typeResolver;
26-
}
2718

28-
public function supports(PhpDocTagNode $node, Context $context): bool
29-
{
30-
return $node->value instanceof ImplementsTagValueNode && $node->name === $this->tagName;
31-
}
3219
}

src/DocBlock/Tags/Factory/ExtendsFactory.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44

55
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
66

7-
use Webmozart\Assert\Assert;
7+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
88
use phpDocumentor\Reflection\DocBlock\Tag;
9+
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
910
use phpDocumentor\Reflection\TypeResolver;
1011
use phpDocumentor\Reflection\Types\Context;
11-
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
12-
use phpDocumentor\Reflection\DocBlock\Tags\Extends_;
1312
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
14-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
13+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
14+
use Webmozart\Assert\Assert;
15+
16+
use function is_string;
1517

1618
/**
1719
* @internal This class is not part of the BC promise of this library.
1820
*/
19-
final class ExtendsFactory extends AbstractExtendsFactory
21+
final class ExtendsFactory implements PHPStanFactory
2022
{
23+
private DescriptionFactory $descriptionFactory;
24+
private TypeResolver $typeResolver;
25+
2126
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
2227
{
23-
parent::__construct($typeResolver, $descriptionFactory);
24-
$this->tagName = '@extends';
28+
$this->descriptionFactory = $descriptionFactory;
29+
$this->typeResolver = $typeResolver;
30+
}
31+
32+
public function supports(PhpDocTagNode $node, Context $context): bool
33+
{
34+
return $node->value instanceof ExtendsTagValueNode && $node->name === '@extends';
2535
}
2636

2737
public function create(PhpDocTagNode $node, Context $context): Tag
@@ -36,7 +46,7 @@ public function create(PhpDocTagNode $node, Context $context): Tag
3646

3747
return new Extends_(
3848
$this->typeResolver->createType($tagValue->type, $context),
39-
$this->descriptionFactory->create($description, $context)
49+
$this->descriptionFactory->create($description, $context)
4050
);
4151
}
4252
}

src/DocBlock/Tags/Factory/ImplementsFactory.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44

55
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
66

7-
use Webmozart\Assert\Assert;
7+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
88
use phpDocumentor\Reflection\DocBlock\Tag;
9+
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
910
use phpDocumentor\Reflection\TypeResolver;
1011
use phpDocumentor\Reflection\Types\Context;
11-
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
12-
use phpDocumentor\Reflection\DocBlock\Tags\Implements_;
13-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
1412
use PHPStan\PhpDocParser\Ast\PhpDoc\ImplementsTagValueNode;
13+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
14+
use Webmozart\Assert\Assert;
15+
16+
use function is_string;
1517

1618
/**
1719
* @internal This class is not part of the BC promise of this library.
1820
*/
1921
final class ImplementsFactory extends AbstractImplementsFactory
2022
{
23+
private DescriptionFactory $descriptionFactory;
24+
private TypeResolver $typeResolver;
25+
2126
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
2227
{
23-
parent::__construct($typeResolver, $descriptionFactory);
24-
$this->tagName = '@implements';
28+
$this->descriptionFactory = $descriptionFactory;
29+
$this->typeResolver = $typeResolver;
30+
}
31+
32+
public function supports(PhpDocTagNode $node, Context $context): bool
33+
{
34+
return $node->value instanceof ImplementsTagValueNode && $node->name === '@implements';
2535
}
2636

2737
public function create(PhpDocTagNode $node, Context $context): Tag
@@ -36,7 +46,7 @@ public function create(PhpDocTagNode $node, Context $context): Tag
3646

3747
return new Implements_(
3848
$this->typeResolver->createType($tagValue->type, $context),
39-
$this->descriptionFactory->create($description, $context)
49+
$this->descriptionFactory->create($description, $context)
4050
);
4151
}
4252
}

src/DocBlock/Tags/Factory/TemplateExtendsFactory.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44

55
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
66

7-
use Webmozart\Assert\Assert;
7+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
88
use phpDocumentor\Reflection\DocBlock\Tag;
9+
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
910
use phpDocumentor\Reflection\TypeResolver;
1011
use phpDocumentor\Reflection\Types\Context;
11-
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
1212
use PHPStan\PhpDocParser\Ast\PhpDoc\ExtendsTagValueNode;
13-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
14-
use phpDocumentor\Reflection\DocBlock\Tags\TemplateExtends;
13+
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
14+
use Webmozart\Assert\Assert;
15+
16+
use function is_string;
1517

1618
/**
1719
* @internal This class is not part of the BC promise of this library.
1820
*/
19-
final class TemplateExtendsFactory extends AbstractExtendsFactory
21+
final class TemplateExtendsFactory implements PHPStanFactory
2022
{
23+
private DescriptionFactory $descriptionFactory;
24+
private TypeResolver $typeResolver;
25+
2126
public function __construct(TypeResolver $typeResolver, DescriptionFactory $descriptionFactory)
2227
{
23-
parent::__construct($typeResolver, $descriptionFactory);
24-
$this->tagName = '@template-extends';
28+
$this->descriptionFactory = $descriptionFactory;
29+
$this->typeResolver = $typeResolver;
30+
}
31+
32+
public function supports(PhpDocTagNode $node, Context $context): bool
33+
{
34+
return $node->value instanceof ExtendsTagValueNode && $node->name === '@template-extends';
2535
}
2636

2737
public function create(PhpDocTagNode $node, Context $context): Tag
@@ -36,7 +46,7 @@ public function create(PhpDocTagNode $node, Context $context): Tag
3646

3747
return new TemplateExtends(
3848
$this->typeResolver->createType($tagValue->type, $context),
39-
$this->descriptionFactory->create($description, $context)
49+
$this->descriptionFactory->create($description, $context)
4050
);
4151
}
4252
}

src/DocBlock/Tags/Factory/TemplateFactory.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
66

7-
use Webmozart\Assert\Assert;
7+
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
88
use phpDocumentor\Reflection\DocBlock\Tag;
9+
use phpDocumentor\Reflection\DocBlock\Tags\Template;
910
use phpDocumentor\Reflection\TypeResolver;
1011
use phpDocumentor\Reflection\Types\Context;
1112
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
12-
use phpDocumentor\Reflection\DocBlock\Tags\Template;
13-
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
1413
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
14+
use Webmozart\Assert\Assert;
15+
16+
use function is_string;
1517

1618
/**
1719
* @internal This class is not part of the BC promise of this library.
@@ -30,18 +32,23 @@ public function __construct(TypeResolver $typeResolver, DescriptionFactory $desc
3032
public function create(PhpDocTagNode $node, Context $context): Tag
3133
{
3234
$tagValue = $node->value;
35+
3336
Assert::isInstanceOf($tagValue, TemplateTagValueNode::class);
37+
$name = $tagValue->name;
38+
if ($name === '') {
39+
throw new \InvalidArgumentException('Template name cannot be empty');
40+
}
3441

3542
$description = $tagValue->getAttribute('description');
3643
if (is_string($description) === false) {
3744
$description = $tagValue->description;
3845
}
3946

4047
return new Template(
41-
$tagValue->name,
48+
$name,
4249
$this->typeResolver->createType($tagValue->bound, $context),
4350
$this->typeResolver->createType($tagValue->default, $context),
44-
$this->descriptionFactory->create($description, $context)
51+
$this->descriptionFactory->create($description, $context)
4552
);
4653
}
4754

0 commit comments

Comments
 (0)