Skip to content

Commit b66b6dc

Browse files
committed
Fix some php8+ issues
1 parent c6f6e2d commit b66b6dc

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

phpcs.xml.dist

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010

1111
<!-- Set the minimum PHP version for PHPCompatibility.
1212
This should be kept in sync with the requirements in the composer.json file. -->
13-
<config name="testVersion" value="7.2-"/>
13+
<config name="testVersion" value="7.4-"/>
1414

1515
<rule ref="phpDocumentor">
1616
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException" />
17-
18-
<!-- Property type declarations are a PHP 7.4 feature. -->
19-
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
2017
</rule>
2118

2219
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">

src/DocBlock/StandardTagFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@
4141
use ReflectionParameter;
4242
use Webmozart\Assert\Assert;
4343

44+
use function array_key_exists;
4445
use function array_merge;
4546
use function array_slice;
4647
use function call_user_func_array;
4748
use function count;
4849
use function get_class;
4950
use function is_object;
5051
use function preg_match;
52+
use function sprintf;
5153
use function strpos;
5254
use function trim;
5355

@@ -164,6 +166,7 @@ public function addService(object $service, ?string $alias = null): void
164166
$this->serviceLocator[$alias ?: get_class($service)] = $service;
165167
}
166168

169+
/** {@inheritDoc} */
167170
public function registerTagHandler(string $tagName, $handler): void
168171
{
169172
Assert::stringNotEmpty($tagName);
@@ -176,6 +179,7 @@ public function registerTagHandler(string $tagName, $handler): void
176179
if (is_object($handler)) {
177180
Assert::implementsInterface($handler, TagFactory::class);
178181
$this->tagHandlerMappings[$tagName] = $handler;
182+
179183
return;
180184
}
181185

@@ -217,7 +221,9 @@ private function createTag(string $body, string $name, TypeContext $context): Ta
217221
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
218222
);
219223

220-
$arguments['tagLine'] = sprintf('@%s %s', $name, $body);
224+
if (array_key_exists('tagLine', $arguments)) {
225+
$arguments['tagLine'] = sprintf('@%s %s', $name, $body);
226+
}
221227

222228
try {
223229
$callable = [$handlerClassName, 'create'];

src/DocBlock/TagFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use InvalidArgumentException;
1717
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
18-
use phpDocumentor\Reflection\Types\Context as TypeContext;
1918

2019
interface TagFactory extends Factory
2120
{
@@ -61,7 +60,7 @@ public function addService(object $service): void;
6160
*
6261
* @param string $tagName Name of tag to register a handler for. When registering a namespaced
6362
* tag, the full name, along with a prefixing slash MUST be provided.
64-
* @param class-string<Tag> $handler FQCN of handler.
63+
* @param class-string<Tag>|Factory $handler FQCN of handler.
6564
*
6665
* @throws InvalidArgumentException If the tag name is not a string.
6766
* @throws InvalidArgumentException If the tag name is namespaced (contains backslashes) but
@@ -70,5 +69,5 @@ public function addService(object $service): void;
7069
* @throws InvalidArgumentException If the handler is not an existing class.
7170
* @throws InvalidArgumentException If the handler does not implement the {@see Tag} interface.
7271
*/
73-
public function registerTagHandler(string $tagName, string $handler): void;
72+
public function registerTagHandler(string $tagName, $handler): void;
7473
}

src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313

1414
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
1515

16-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
1716
use phpDocumentor\Reflection\DocBlock\Tag;
18-
use phpDocumentor\Reflection\DocBlock\TagFactory;
1917
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
2018
use phpDocumentor\Reflection\Types\Context as TypeContext;
2119
use PHPStan\PhpDocParser\Lexer\Lexer;
@@ -36,6 +34,7 @@ class AbstractPHPStanFactory implements Factory
3634
{
3735
private PhpDocParser $parser;
3836
private Lexer $lexer;
37+
/** @var PHPStanFactory[] */
3938
private array $factories;
4039

4140
public function __construct(PHPStanFactory ...$factories)

src/DocBlock/Tags/Factory/Factory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
interface Factory
3030
{
31-
3231
/**
3332
* Factory method responsible for instantiating the correct sub type.
3433
*

src/DocBlockFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
use InvalidArgumentException;
1717
use LogicException;
1818
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
19-
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
2019
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
2120
use phpDocumentor\Reflection\DocBlock\Tag;
2221
use phpDocumentor\Reflection\DocBlock\TagFactory;
2322
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
23+
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
2424
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
2525
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TypeFactory;
2626
use Webmozart\Assert\Assert;
@@ -42,7 +42,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
4242
/** @var DocBlock\DescriptionFactory */
4343
private $descriptionFactory;
4444

45-
/** @var \phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory */
45+
/** @var Factory */
4646
private $tagFactory;
4747

4848
/**

tests/unit/DocBlock/StandardTagFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public function testPassingYourOwnSetOfTagHandlersWithoutComment(): void
228228

229229
public function testTagWithHandlerObject(): void
230230
{
231-
$fqsenResolver = new FqsenResolver();
231+
$fqsenResolver = new FqsenResolver();
232232

233233
$customFactory = new CustomTagFactory();
234234
$injectedClass = new CustomServiceClass();

0 commit comments

Comments
 (0)