mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-23 19:24:48 +01:00
prepare support for multi-types [ref #97]
This commit is contained in:
parent
7f05c600f7
commit
c4c98d27c1
@ -47,7 +47,7 @@ final class MethodCallTypeResolver implements PerNodeTypeResolverInterface
|
||||
$variableNode = $methodCallNode->var;
|
||||
|
||||
if (! $variableNode instanceof Variable) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
$variableName = $variableNode->name;
|
||||
@ -58,7 +58,7 @@ final class MethodCallTypeResolver implements PerNodeTypeResolverInterface
|
||||
|
||||
// 2. get method() return type
|
||||
if (! $methodCallVariableTypes || ! $methodCallName) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
$methodCallVariableType = array_pop($methodCallVariableTypes);
|
||||
@ -67,7 +67,7 @@ final class MethodCallTypeResolver implements PerNodeTypeResolverInterface
|
||||
if ($variableType) {
|
||||
$variableName = $this->getVariableToAssignTo($methodCallNode);
|
||||
if ($variableName === null) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
$this->typeContext->addVariableWithTypes($variableName, [$variableType]);
|
||||
|
@ -52,7 +52,7 @@ final class VariableTypeResolver implements PerNodeTypeResolverInterface, NodeTy
|
||||
return $this->nodeTypeResolver->resolve($variableNode->name);
|
||||
}
|
||||
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
public function setNodeTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
|
@ -120,8 +120,7 @@ final class TypeContext
|
||||
|
||||
public function addAssign(string $newVariable, string $oldVariable): void
|
||||
{
|
||||
$variableTypes = $this->getTypesForVariable($oldVariable);
|
||||
$this->addVariableWithTypes($newVariable, $variableTypes);
|
||||
$this->addVariableWithTypes($newVariable, $this->getTypesForVariable($oldVariable));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user