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)) {
|
||||
Assert::implementsInterface($handler, Factory::class);
|
||||
Assert::isInstanceOf($handler, Factory::class);
|
||||
$this->tagHandlerMappings[$tagName] = $handler;
|
||||
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,10 @@ final class MethodFactory implements PHPStanFactory
|
||||
function (MethodTagValueParameterNode $param) use ($context) {
|
||||
return new MethodParameter(
|
||||
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->isVariadic,
|
||||
(string) $param->defaultValue
|
||||
@@ -69,6 +72,10 @@ final class MethodFactory implements PHPStanFactory
|
||||
|
||||
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 MethodParameter[] $parameters
|
||||
* @phpstan-param array<int, array{name: string, type: Type}|string> $arguments
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -90,6 +91,10 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
$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(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
@@ -261,7 +266,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
{
|
||||
$arguments = [];
|
||||
foreach ($this->parameters as $parameter) {
|
||||
$arguments[] = ($parameter->getType() ?? new Mixed_()) . ' ' .
|
||||
$arguments[] = $parameter->getType() . ' ' .
|
||||
($parameter->isReference() ? '&' : '') .
|
||||
($parameter->isVariadic() ? '...' : '') .
|
||||
'$' . $parameter->getName();
|
||||
@@ -334,6 +339,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
||||
|
||||
/**
|
||||
* @param array{name: string, type: Type} $arguments
|
||||
* @phpstan-param array<int, array{name: string, type: Type}> $arguments
|
||||
*
|
||||
* @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(
|
||||
string $body,
|
||||
@@ -69,7 +70,11 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -49,13 +49,21 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -49,13 +49,21 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -49,13 +49,21 @@ final class PropertyWrite extends TagWithType implements Factory\StaticMethod
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
@@ -36,13 +36,21 @@ final class Return_ extends TagWithType implements Factory\StaticMethod
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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($descriptionFactory);
|
||||
|
||||
|
||||
@@ -49,13 +49,21 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Create using static factory is deprecated,
|
||||
* this method should not be called directly by library consumers
|
||||
*/
|
||||
public static function create(
|
||||
string $body,
|
||||
?TypeResolver $typeResolver = null,
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): 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::notNull($typeResolver);
|
||||
Assert::notNull($descriptionFactory);
|
||||
|
||||
Reference in New Issue
Block a user