mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Add default types to method tag arguments
This commit is contained in:
@@ -10,6 +10,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
|||||||
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
||||||
use phpDocumentor\Reflection\Type;
|
use phpDocumentor\Reflection\Type;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
|
use phpDocumentor\Reflection\Types\Mixed_;
|
||||||
use phpDocumentor\Reflection\Types\Void_;
|
use phpDocumentor\Reflection\Types\Void_;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueParameterNode;
|
||||||
@@ -49,7 +50,7 @@ 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->typeFactory->createType($param->type, $context),
|
$this->typeFactory->createType($param->type, $context) ?? new Mixed_(),
|
||||||
$param->isReference,
|
$param->isReference,
|
||||||
$param->isVariadic,
|
$param->isVariadic,
|
||||||
(string) $param->defaultValue
|
(string) $param->defaultValue
|
||||||
|
|||||||
@@ -328,6 +328,7 @@ final class Method extends BaseTag implements Factory\StaticMethod
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{name: string, type: Type} $arguments
|
* @param array{name: string, type: Type} $arguments
|
||||||
|
*
|
||||||
* @return MethodParameter[]
|
* @return MethodParameter[]
|
||||||
*/
|
*/
|
||||||
private function fromLegacyArguments(array $arguments): array
|
private function fromLegacyArguments(array $arguments): array
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ use phpDocumentor\Reflection\DocBlock\Tags\Method;
|
|||||||
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
use phpDocumentor\Reflection\DocBlock\Tags\MethodParameter;
|
||||||
use phpDocumentor\Reflection\Types\Context;
|
use phpDocumentor\Reflection\Types\Context;
|
||||||
use phpDocumentor\Reflection\Types\Integer;
|
use phpDocumentor\Reflection\Types\Integer;
|
||||||
|
use phpDocumentor\Reflection\Types\Mixed_;
|
||||||
use phpDocumentor\Reflection\Types\String_;
|
use phpDocumentor\Reflection\Types\String_;
|
||||||
use phpDocumentor\Reflection\Types\Void_;
|
use phpDocumentor\Reflection\Types\Void_;
|
||||||
|
|
||||||
@@ -82,6 +83,30 @@ final class MethodFactoryTest extends TagFactoryTestCase
|
|||||||
[]
|
[]
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'@method myMethod($a)',
|
||||||
|
new Method(
|
||||||
|
'myMethod',
|
||||||
|
[],
|
||||||
|
new Void_(),
|
||||||
|
false,
|
||||||
|
new Description(''),
|
||||||
|
false,
|
||||||
|
[new MethodParameter('a', new Mixed_())]
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'@method myMethod($a = 1)',
|
||||||
|
new Method(
|
||||||
|
'myMethod',
|
||||||
|
[],
|
||||||
|
new Void_(),
|
||||||
|
false,
|
||||||
|
new Description(''),
|
||||||
|
false,
|
||||||
|
[new MethodParameter('a', new Mixed_(), false, false, '1')]
|
||||||
|
),
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'@method myMethod(int $a = 1)',
|
'@method myMethod(int $a = 1)',
|
||||||
new Method(
|
new Method(
|
||||||
|
|||||||
Reference in New Issue
Block a user