|
17 | 17 | use phpDocumentor\Reflection\Php\ProjectFactoryStrategy; |
18 | 18 | use phpDocumentor\Reflection\Php\StrategyContainer; |
19 | 19 | use phpDocumentor\Reflection\PrettyPrinter; |
20 | | -use phpDocumentor\Reflection\Type; |
21 | | -use phpDocumentor\Reflection\TypeResolver; |
22 | 20 | use phpDocumentor\Reflection\Types\Context; |
23 | 21 | use PhpParser\Node\Expr\Variable; |
24 | | -use PhpParser\Node\NullableType; |
25 | 22 | use PhpParser\Node\Param; |
26 | | -use PhpParser\Node\UnionType; |
27 | 23 | use Webmozart\Assert\Assert; |
28 | 24 |
|
29 | 25 | /** |
@@ -66,34 +62,13 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co |
66 | 62 | { |
67 | 63 | Assert::isInstanceOf($object, Param::class); |
68 | 64 | Assert::isInstanceOf($object->var, Variable::class); |
69 | | - $default = null; |
70 | | - if ($object->default !== null) { |
71 | | - $default = $this->valueConverter->prettyPrintExpr($object->default); |
72 | | - } |
73 | 65 |
|
74 | | - $type = null; |
75 | | - if (!empty($object->type)) { |
76 | | - $type = $this->createType($object); |
77 | | - } |
78 | | - |
79 | | - return new ArgumentDescriptor((string) $object->var->name, $type, $default, $object->byRef, $object->variadic); |
80 | | - } |
81 | | - |
82 | | - private function createType(Param $arg, ?Context $context = null) : ?Type |
83 | | - { |
84 | | - if ($arg->type === null) { |
85 | | - return null; |
86 | | - } |
87 | | - |
88 | | - $typeResolver = new TypeResolver(); |
89 | | - if ($arg->type instanceof NullableType) { |
90 | | - $typeString = '?' . $arg->type->type; |
91 | | - } elseif ($arg->type instanceof UnionType) { |
92 | | - $typeString = $arg->type->getType(); |
93 | | - } else { |
94 | | - $typeString = $arg->type->toString(); |
95 | | - } |
96 | | - |
97 | | - return $typeResolver->resolve($typeString, $context); |
| 66 | + return new ArgumentDescriptor( |
| 67 | + (string) $object->var->name, |
| 68 | + (new Type())->fromPhpParser($object->type), |
| 69 | + $object->default !== null ? $this->valueConverter->prettyPrintExpr($object->default) : null, |
| 70 | + $object->byRef, |
| 71 | + $object->variadic |
| 72 | + ); |
98 | 73 | } |
99 | 74 | } |
0 commit comments