Skip to content

Commit

Permalink
Merge 0cde2cd into 5231473
Browse files Browse the repository at this point in the history
  • Loading branch information
jaapio committed Aug 9, 2018
2 parents 5231473 + 0cde2cd commit e2f7e2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/phpDocumentor/Reflection/Php/Factory/Argument.php
Expand Up @@ -18,8 +18,11 @@
use phpDocumentor\Reflection\Php\ProjectFactoryStrategy;
use phpDocumentor\Reflection\Php\StrategyContainer;
use phpDocumentor\Reflection\PrettyPrinter;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\NullableType;
use PhpParser\Node\Param;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -68,6 +71,23 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
$default = $this->valueConverter->prettyPrintExpr($object->default);
}

return new ArgumentDescriptor((string) $object->var->name, $default, $object->byRef, $object->variadic);
$argumentDescriptor = new ArgumentDescriptor((string) $object->var->name, $default, $object->byRef, $object->variadic);

if (!empty($object->type)) {
$argumentDescriptor->addType($this->createType($object));
}

return $argumentDescriptor;
}

private function createType(Param $arg, ?Context $context = null): Type
{
$typeResolver = new TypeResolver();
$typeString = (string) $arg->type;
if ($arg->type instanceof NullableType) {
$typeString = '?' . $arg->type;
}

return $typeResolver->resolve($typeString, $context);
}
}
1 change: 1 addition & 0 deletions tests/component/ProjectCreationTest.php
Expand Up @@ -105,6 +105,7 @@ public function testWithNamespacedClass()
);

$this->assertEquals('style', $methods['\\Luigi\\Pizza::__construct()']->getArguments()[0]->getName());
$this->assertEquals([new Object_(new Fqsen('\\Luigi\\Pizza\Style'))], $methods['\\Luigi\\Pizza::__construct()']->getArguments()[0]->getTypes());
}

public function testDocblockOfMethodIsProcessed()
Expand Down

0 comments on commit e2f7e2c

Please sign in to comment.