mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Fix some php8+ issues
This commit is contained in:
@@ -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'];
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -28,7 +28,6 @@ use phpDocumentor\Reflection\Types\Context as TypeContext;
|
||||
|
||||
interface Factory
|
||||
{
|
||||
|
||||
/**
|
||||
* Factory method responsible for instantiating the correct sub type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user