mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-27 04:24:43 +01:00
Fix NameResolver for parameters without typehints
This commit is contained in:
parent
b84553e011
commit
d9452e611a
@ -51,22 +51,23 @@ class PHPParser_NodeVisitor_NameResolver extends PHPParser_NodeVisitorAbstract
|
|||||||
|| $node instanceof PHPParser_Node_Expr_New
|
|| $node instanceof PHPParser_Node_Expr_New
|
||||||
|| $node instanceof PHPParser_Node_Expr_Instanceof
|
|| $node instanceof PHPParser_Node_Expr_Instanceof
|
||||||
) {
|
) {
|
||||||
$node->class = $this->resolveClassName($node->class);
|
if ($node->class instanceof PHPParser_Node_Name) {
|
||||||
|
$node->class = $this->resolveClassName($node->class);
|
||||||
|
}
|
||||||
} elseif ($node instanceof PHPParser_Node_Expr_FuncCall
|
} elseif ($node instanceof PHPParser_Node_Expr_FuncCall
|
||||||
|| $node instanceof PHPParser_Node_Expr_ConstFetch
|
|| $node instanceof PHPParser_Node_Expr_ConstFetch
|
||||||
) {
|
) {
|
||||||
$node->name = $this->resolveOtherName($node->name);
|
if ($node->name instanceof PHPParser_Node_Name) {
|
||||||
} elseif ($node instanceof PHPParser_Node_Param) {
|
$node->name = $this->resolveOtherName($node->name);
|
||||||
|
}
|
||||||
|
} elseif ($node instanceof PHPParser_Node_Param
|
||||||
|
&& $node instanceof PHPParser_Node_Name
|
||||||
|
) {
|
||||||
$node->type = $this->resolveClassName($node->type);
|
$node->type = $this->resolveClassName($node->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function resolveClassName(PHPParser_Node $name) {
|
protected function resolveClassName(PHPParser_Node_Name $name) {
|
||||||
// can't resolve dynamic names at compile-time
|
|
||||||
if (!$name instanceof PHPParser_Node_Name) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't resolve special class names
|
// don't resolve special class names
|
||||||
if (in_array((string) $name, array('self', 'parent', 'static'))) {
|
if (in_array((string) $name, array('self', 'parent', 'static'))) {
|
||||||
return $name;
|
return $name;
|
||||||
@ -88,12 +89,7 @@ class PHPParser_NodeVisitor_NameResolver extends PHPParser_NodeVisitorAbstract
|
|||||||
return new PHPParser_Node_Name_FullyQualified($name->parts);
|
return new PHPParser_Node_Name_FullyQualified($name->parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function resolveOtherName(PHPParser_Node $name) {
|
protected function resolveOtherName(PHPParser_Node_Name $name) {
|
||||||
// can't resolve dynamic names at compile-time
|
|
||||||
if (!$name instanceof PHPParser_Node_Name) {
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fully qualified names are already resolved and we can't do anything about unqualified
|
// fully qualified names are already resolved and we can't do anything about unqualified
|
||||||
// ones at compiler-time
|
// ones at compiler-time
|
||||||
if ($name->isFullyQualified() || $name->isUnqualified()) {
|
if ($name->isFullyQualified() || $name->isUnqualified()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user