mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Perform NullableType resolution earlier
This makes sure function signatures are already fully resolved in enterNode(). Resolves issue #360.
This commit is contained in:
parent
0bf561dfe7
commit
1b59e918f7
@ -172,13 +172,20 @@ class NameResolver extends NodeVisitorAbstract
|
||||
/** @param Stmt\Function_|Stmt\ClassMethod|Expr\Closure $node */
|
||||
private function resolveSignature($node) {
|
||||
foreach ($node->params as $param) {
|
||||
if ($param->type instanceof Name) {
|
||||
$param->type = $this->resolveClassName($param->type);
|
||||
$param->type = $this->resolveType($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) {
|
||||
|
Loading…
Reference in New Issue
Block a user