Fix some php8+ issues

This commit is contained in:
Jaapio
2022-10-28 14:54:08 +02:00
parent c6f6e2d523
commit b66b6dc644
7 changed files with 14 additions and 14 deletions
+1 -4
View File
@@ -10,13 +10,10 @@
<!-- Set the minimum PHP version for PHPCompatibility.
This should be kept in sync with the requirements in the composer.json file. -->
<config name="testVersion" value="7.2-"/>
<config name="testVersion" value="7.4-"/>
<rule ref="phpDocumentor">
<exclude name="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException" />
<!-- Property type declarations are a PHP 7.4 feature. -->
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
+7 -1
View File
@@ -41,6 +41,7 @@ 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;
@@ -48,6 +49,7 @@ use function count;
use function get_class;
use function is_object;
use function preg_match;
use function sprintf;
use function strpos;
use function trim;
@@ -164,6 +166,7 @@ final class StandardTagFactory implements TagFactory
$this->serviceLocator[$alias ?: get_class($service)] = $service;
}
/** {@inheritDoc} */
public function registerTagHandler(string $tagName, $handler): void
{
Assert::stringNotEmpty($tagName);
@@ -176,6 +179,7 @@ final class StandardTagFactory implements TagFactory
if (is_object($handler)) {
Assert::implementsInterface($handler, TagFactory::class);
$this->tagHandlerMappings[$tagName] = $handler;
return;
}
@@ -217,7 +221,9 @@ final class StandardTagFactory implements TagFactory
$this->getServiceLocatorWithDynamicParameters($context, $name, $body)
);
$arguments['tagLine'] = sprintf('@%s %s', $name, $body);
if (array_key_exists('tagLine', $arguments)) {
$arguments['tagLine'] = sprintf('@%s %s', $name, $body);
}
try {
$callable = [$handlerClassName, 'create'];
+2 -3
View File
@@ -15,7 +15,6 @@ namespace phpDocumentor\Reflection\DocBlock;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\Types\Context as TypeContext;
interface TagFactory extends Factory
{
@@ -61,7 +60,7 @@ interface TagFactory extends Factory
*
* @param string $tagName Name of tag to register a handler for. When registering a namespaced
* tag, the full name, along with a prefixing slash MUST be provided.
* @param class-string<Tag> $handler FQCN of handler.
* @param class-string<Tag>|Factory $handler FQCN of handler.
*
* @throws InvalidArgumentException If the tag name is not a string.
* @throws InvalidArgumentException If the tag name is namespaced (contains backslashes) but
@@ -70,5 +69,5 @@ interface TagFactory extends Factory
* @throws InvalidArgumentException If the handler is not an existing class.
* @throws InvalidArgumentException If the handler does not implement the {@see Tag} interface.
*/
public function registerTagHandler(string $tagName, string $handler): void;
public function registerTagHandler(string $tagName, $handler): void;
}
@@ -13,9 +13,7 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags\Factory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
use phpDocumentor\Reflection\Types\Context as TypeContext;
use PHPStan\PhpDocParser\Lexer\Lexer;
@@ -36,6 +34,7 @@ class AbstractPHPStanFactory implements Factory
{
private PhpDocParser $parser;
private Lexer $lexer;
/** @var PHPStanFactory[] */
private array $factories;
public function __construct(PHPStanFactory ...$factories)
-1
View File
@@ -28,7 +28,6 @@ use phpDocumentor\Reflection\Types\Context as TypeContext;
interface Factory
{
/**
* Factory method responsible for instantiating the correct sub type.
*
+2 -2
View File
@@ -16,11 +16,11 @@ namespace phpDocumentor\Reflection;
use InvalidArgumentException;
use LogicException;
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TypeFactory;
use Webmozart\Assert\Assert;
@@ -42,7 +42,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
/** @var DocBlock\DescriptionFactory */
private $descriptionFactory;
/** @var \phpDocumentor\Reflection\DocBlock\Tags\Factory\Factory */
/** @var Factory */
private $tagFactory;
/**
@@ -228,7 +228,7 @@ class StandardTagFactoryTest extends TestCase
public function testTagWithHandlerObject(): void
{
$fqsenResolver = new FqsenResolver();
$fqsenResolver = new FqsenResolver();
$customFactory = new CustomTagFactory();
$injectedClass = new CustomServiceClass();