Skip to content

Commit

Permalink
Call Scope::getType() as late as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Dec 21, 2022
1 parent 84d53c7 commit c4baa79
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Type/Php/FilterInputDynamicReturnTypeExtension.php
Expand Up @@ -44,19 +44,18 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,

$inputVariable = $this->determineInputVariable($functionCall->getArgs()[0]);
$varNameType = $scope->getType($functionCall->getArgs()[1]->value);
$filterType = isset($functionCall->getArgs()[2]) ? $scope->getType($functionCall->getArgs()[2]->value) : null;
$flagsType = isset($functionCall->getArgs()[3]) ? $scope->getType($functionCall->getArgs()[3]->value) : null;

if ($inputVariable === null || !$varNameType->isString()->yes()) {
return null;
}

$inputVariableType = $scope->getType($inputVariable);
$inputHasOffsetValue = $inputVariableType->hasOffsetValueType($varNameType);
$flagsType = isset($functionCall->getArgs()[3]) ? $scope->getType($functionCall->getArgs()[3]->value) : null;
if ($inputHasOffsetValue->no()) {
return $this->determineNonExistentOffsetReturnType($flagsType);
}

$filterType = isset($functionCall->getArgs()[2]) ? $scope->getType($functionCall->getArgs()[2]->value) : null;
$filteredType = $this->filterFunctionReturnTypeHelper->getTypeFromFunctionCall(
$inputVariableType->getOffsetValueType($varNameType),
$filterType,
Expand Down

0 comments on commit c4baa79

Please sign in to comment.