mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +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 */
|
/** @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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($node->returnType instanceof Name) {
|
$node->returnType = $this->resolveType($node->returnType);
|
||||||
$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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user