Perform NullableType resolution earlier

This makes sure function signatures are already fully resolved in
enterNode(). Resolves issue #360.
This commit is contained in:
Nikita Popov 2017-02-26 22:50:31 +01:00
parent 0bf561dfe7
commit 1b59e918f7

View File

@ -172,13 +172,20 @@ class NameResolver extends NodeVisitorAbstract
/** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */ /** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */
private function resolveSignature($node) { private function resolveSignature($node) {
foreach ($node->params as $param) { foreach ($node->params as $param) {
if ($param->type instanceof Name) { $param->type = $this->resolveType($param->type);
$param->type = $this->resolveClassName($param->type);
} }
$node->returnType = $this->resolveType($node->returnType);
} }
if ($node->returnType instanceof Name) {
$node->returnType = $this->resolveClassName($node->returnType); private function resolveType($node) {
if ($node instanceof Node\NullableType) {
$node->type = $this->resolveType($node->type);
return $node;
} }
if ($node instanceof Name) {
return $this->resolveClassName($node);
}
return $node;
} }
protected function resolveClassName(Name $name) { protected function resolveClassName(Name $name) {