mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-23 11:14:38 +01:00
prepare support for multi-types [ref #97]
This commit is contained in:
parent
46e366db84
commit
7f05c600f7
@ -45,16 +45,16 @@ final class AssignTypeResolver implements PerNodeTypeResolverInterface, NodeType
|
||||
return [];
|
||||
}
|
||||
|
||||
$variableType = $this->resolveTypeForRightSide($assignNode);
|
||||
$variableTypes = $this->resolveTypeForRightSide($assignNode);
|
||||
|
||||
if ($variableType) {
|
||||
if ($variableTypes) {
|
||||
/** @var Variable $variableNode */
|
||||
$variableNode = $assignNode->var;
|
||||
$variableName = $variableNode->name;
|
||||
$this->typeContext->addVariableWithTypes($variableName, $variableType);
|
||||
$this->typeContext->addVariableWithTypes($variableName, $variableTypes);
|
||||
}
|
||||
|
||||
return [$variableType];
|
||||
return [$variableTypes];
|
||||
}
|
||||
|
||||
public function setNodeTypeResolver(NodeTypeResolver $nodeTypeResolver): void
|
||||
|
@ -74,7 +74,7 @@ final class ParamTypeResolver implements PerNodeTypeResolverInterface, NodeTypeR
|
||||
// resolve param type from docblock
|
||||
$paramType = $this->docBlockAnalyzer->getParamTypeFor($classMethod, $variableName);
|
||||
if ($paramType === null) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
|
||||
// resolve to FQN
|
||||
|
@ -92,7 +92,12 @@ final class TypeContext
|
||||
$functionReflection = $this->getFunctionReflection($functionLikeNode);
|
||||
if ($functionReflection) {
|
||||
foreach ($functionReflection->getParameters() as $parameterReflection) {
|
||||
$this->variableTypes[$parameterReflection->getName()] = (string) $parameterReflection->getType();
|
||||
$type = (string) $parameterReflection->getType();
|
||||
if (! $type) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->variableTypes[$parameterReflection->getName()] = [$type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user