mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Codestyle fixes and static analysis
This commit is contained in:
@@ -177,7 +177,7 @@ final class StandardTagFactory implements TagFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_object($handler)) {
|
if (is_object($handler)) {
|
||||||
Assert::implementsInterface($handler, Factory::class);
|
Assert::isInstanceOf($handler, Factory::class);
|
||||||
$this->tagHandlerMappings[$tagName] = $handler;
|
$this->tagHandlerMappings[$tagName] = $handler;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ final class MethodFactory implements PHPStanFactory
|
|||||||
function (MethodTagValueParameterNode $param) use ($context) {
|
function (MethodTagValueParameterNode $param) use ($context) {
|
||||||
return new MethodParameter(
|
return new MethodParameter(
|
||||||
trim($param->parameterName, '$'),
|
trim($param->parameterName, '$'),
|
||||||
$this->typeResolver->createType($param->type, $context) ?? new Mixed_(),
|
$param->type === null ? new Mixed_() : $this->typeResolver->createType(
|
||||||
|
$param->type,
|
||||||
|
$context
|
||||||
|
),
|
||||||
$param->isReference,
|
$param->isReference,
|
||||||
$param->isVariadic,
|
$param->isVariadic,
|
||||||
(string) $param->defaultValue
|
(string) $param->defaultValue
|
||||||
@@ -69,6 +72,10 @@ final class MethodFactory implements PHPStanFactory
|
|||||||
|
|
||||||
private function createReturnType(MethodTagValueNode $tagValue, Context $context): Type
|
private function createReturnType(MethodTagValueNode $tagValue, Context $context): Type
|
||||||
{
|
{
|
||||||
return $this->typeResolver->createType($tagValue->returnType, $context) ?? new Void_();
|
if ($tagValue->returnType === null) {
|
||||||
|
return new Void_();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->typeResolver->createType($tagValue->returnType, $context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int, array<string, Type|string>> $arguments
|
* @param array<int, array<string, Type|string>> $arguments
|
||||||
|
* @param MethodParameter[] $parameters
|
||||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -90,6 +91,10 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
$this->parameters = $parameters ?? $this->fromLegacyArguments($arguments);
|
$this->parameters = $parameters ?? $this->fromLegacyArguments($arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
@@ -261,7 +266,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
{
|
{
|
||||||
$arguments = [];
|
$arguments = [];
|
||||||
foreach ($this->parameters as $parameter) {
|
foreach ($this->parameters as $parameter) {
|
||||||
$arguments[] = ($parameter->getType() ?? new Mixed_()) . ' ' .
|
$arguments[] = $parameter->getType() . ' ' .
|
||||||
($parameter->isReference() ? '&' : '') .
|
($parameter->isReference() ? '&' : '') .
|
||||||
($parameter->isVariadic() ? '...' : '') .
|
($parameter->isVariadic() ? '...' : '') .
|
||||||
'$' . $parameter->getName();
|
'$' . $parameter->getName();
|
||||||
@@ -334,6 +339,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{name: string, type: Type} $arguments
|
* @param array{name: string, type: Type} $arguments
|
||||||
|
* @phpstan-param array<int, array{name: string, type: Type}> $arguments
|
||||||
*
|
*
|
||||||
* @return MethodParameter[]
|
* @return MethodParameter[]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Create using static factory is deprecated, this method should not be called directly by library consumers
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
*/
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
@@ -69,7 +70,11 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
|||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|||||||
@@ -49,13 +49,21 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|||||||
@@ -49,13 +49,21 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|||||||
@@ -49,13 +49,21 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|||||||
@@ -36,13 +36,21 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|
||||||
|
|||||||
@@ -49,13 +49,21 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
|||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Create using static factory is deprecated,
|
||||||
|
* this method should not be called directly by library consumers
|
||||||
|
*/
|
||||||
public static function create(
|
public static function create(
|
||||||
string $body,
|
string $body,
|
||||||
?TypeResolver $typeResolver = null,
|
?TypeResolver $typeResolver = null,
|
||||||
?DescriptionFactory $descriptionFactory = null,
|
?DescriptionFactory $descriptionFactory = null,
|
||||||
?TypeContext $context = null
|
?TypeContext $context = null
|
||||||
): self {
|
): self {
|
||||||
trigger_error('Create using static factory is deprecated, this method should not be called directly by library consumers', E_USER_DEPRECATED);
|
trigger_error(
|
||||||
|
'Create using static factory is deprecated, this method should not be called directly
|
||||||
|
by library consumers',
|
||||||
|
E_USER_DEPRECATED
|
||||||
|
);
|
||||||
Assert::stringNotEmpty($body);
|
Assert::stringNotEmpty($body);
|
||||||
Assert::notNull($typeResolver);
|
Assert::notNull($typeResolver);
|
||||||
Assert::notNull($descriptionFactory);
|
Assert::notNull($descriptionFactory);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ 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\ReturnFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory;
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\TypeFactory;
|
|
||||||
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
use phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory;
|
||||||
use Webmozart\Assert\Assert;
|
use Webmozart\Assert\Assert;
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ final class DocBlockFactory implements DocBlockFactoryInterface
|
|||||||
*
|
*
|
||||||
* @param array<string, class-string<Tag>|Factory> $additionalTags
|
* @param array<string, class-string<Tag>|Factory> $additionalTags
|
||||||
*/
|
*/
|
||||||
public static function createInstance(array $additionalTags = []): self
|
public static function createInstance(array $additionalTags = []): DocBlockFactoryInterface
|
||||||
{
|
{
|
||||||
$fqsenResolver = new FqsenResolver();
|
$fqsenResolver = new FqsenResolver();
|
||||||
$tagFactory = new StandardTagFactory($fqsenResolver);
|
$tagFactory = new StandardTagFactory($fqsenResolver);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
@@ -88,7 +88,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
@@ -100,7 +100,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
@@ -112,7 +112,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
@@ -124,7 +124,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
@@ -136,7 +136,7 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
new Method(
|
new Method(
|
||||||
'myMethod',
|
'myMethod',
|
||||||
[],
|
[],
|
||||||
new Mixed_(),
|
new Void_(),
|
||||||
false,
|
false,
|
||||||
new Description(''),
|
new Description(''),
|
||||||
false,
|
false,
|
||||||
|
|||||||
Reference in New Issue
Block a user