From c4baa7982a98418725df2a3e7f8fc129d9839884 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Wed, 21 Dec 2022 09:10:24 +0100 Subject: [PATCH] Call Scope::getType() as late as possible --- src/Type/Php/FilterInputDynamicReturnTypeExtension.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Type/Php/FilterInputDynamicReturnTypeExtension.php b/src/Type/Php/FilterInputDynamicReturnTypeExtension.php index 5e7c583e743..0b5a9dba01d 100644 --- a/src/Type/Php/FilterInputDynamicReturnTypeExtension.php +++ b/src/Type/Php/FilterInputDynamicReturnTypeExtension.php @@ -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,