diff --git a/src/Type/Php/ArrayFillFunctionReturnTypeExtension.php b/src/Type/Php/ArrayFillFunctionReturnTypeExtension.php index 268f9aa277..76fb917366 100644 --- a/src/Type/Php/ArrayFillFunctionReturnTypeExtension.php +++ b/src/Type/Php/ArrayFillFunctionReturnTypeExtension.php @@ -41,10 +41,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, return ParametersAcceptorSelector::selectSingle($functionReflection->getVariants())->getReturnType(); } - $startIndexType = $scope->getType($functionCall->getArgs()[0]->value); $numberType = $scope->getType($functionCall->getArgs()[1]->value); - $valueType = $scope->getType($functionCall->getArgs()[2]->value); - $isValidNumberType = IntegerRangeType::fromInterval(0, null)->isSuperTypeOf($numberType); // check against negative-int, which is not allowed @@ -55,6 +52,9 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, return new ConstantBooleanType(false); } + $startIndexType = $scope->getType($functionCall->getArgs()[0]->value); + $valueType = $scope->getType($functionCall->getArgs()[2]->value); + if ( $startIndexType instanceof ConstantIntegerType && $numberType instanceof ConstantIntegerType diff --git a/src/Type/Php/ArraySliceFunctionReturnTypeExtension.php b/src/Type/Php/ArraySliceFunctionReturnTypeExtension.php index 0decfb88d8..0d56e3d54d 100644 --- a/src/Type/Php/ArraySliceFunctionReturnTypeExtension.php +++ b/src/Type/Php/ArraySliceFunctionReturnTypeExtension.php @@ -34,14 +34,14 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, $offsetType = isset($functionCall->getArgs()[1]) ? $scope->getType($functionCall->getArgs()[1]->value) : null; $offset = $offsetType instanceof ConstantIntegerType ? $offsetType->getValue() : 0; - $limitType = isset($functionCall->getArgs()[2]) ? $scope->getType($functionCall->getArgs()[2]->value) : null; - $limit = $limitType instanceof ConstantIntegerType ? $limitType->getValue() : null; - - $preserveKeysType = isset($functionCall->getArgs()[3]) ? $scope->getType($functionCall->getArgs()[3]->value) : null; - $preserveKeys = $preserveKeysType instanceof ConstantBooleanType ? $preserveKeysType->getValue() : false; - $constantArrays = $valueType->getConstantArrays(); if (count($constantArrays) > 0) { + $limitType = isset($functionCall->getArgs()[2]) ? $scope->getType($functionCall->getArgs()[2]->value) : null; + $limit = $limitType instanceof ConstantIntegerType ? $limitType->getValue() : null; + + $preserveKeysType = isset($functionCall->getArgs()[3]) ? $scope->getType($functionCall->getArgs()[3]->value) : null; + $preserveKeys = $preserveKeysType instanceof ConstantBooleanType ? $preserveKeysType->getValue() : false; + $results = []; foreach ($constantArrays as $constantArray) { $results[] = $constantArray->slice($offset, $limit, $preserveKeys); diff --git a/src/Type/Php/IsAFunctionTypeSpecifyingExtension.php b/src/Type/Php/IsAFunctionTypeSpecifyingExtension.php index 2e03074b37..23212393ec 100644 --- a/src/Type/Php/IsAFunctionTypeSpecifyingExtension.php +++ b/src/Type/Php/IsAFunctionTypeSpecifyingExtension.php @@ -37,15 +37,16 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n if (count($node->getArgs()) < 2) { return new SpecifiedTypes(); } - $objectOrClassType = $scope->getType($node->getArgs()[0]->value); $classType = $scope->getType($node->getArgs()[1]->value); - $allowStringType = isset($node->getArgs()[2]) ? $scope->getType($node->getArgs()[2]->value) : new ConstantBooleanType(false); - $allowString = !$allowStringType->equals(new ConstantBooleanType(false)); if (!$classType instanceof ConstantStringType && !$context->truthy()) { return new SpecifiedTypes([], []); } + $objectOrClassType = $scope->getType($node->getArgs()[0]->value); + $allowStringType = isset($node->getArgs()[2]) ? $scope->getType($node->getArgs()[2]->value) : new ConstantBooleanType(false); + $allowString = !$allowStringType->equals(new ConstantBooleanType(false)); + return $this->typeSpecifier->create( $node->getArgs()[0]->value, $this->isAFunctionTypeSpecifyingHelper->determineType($objectOrClassType, $classType, $allowString, true), diff --git a/src/Type/Php/ParseUrlFunctionDynamicReturnTypeExtension.php b/src/Type/Php/ParseUrlFunctionDynamicReturnTypeExtension.php index 0bb98aaa1e..d6e608c851 100644 --- a/src/Type/Php/ParseUrlFunctionDynamicReturnTypeExtension.php +++ b/src/Type/Php/ParseUrlFunctionDynamicReturnTypeExtension.php @@ -56,7 +56,6 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, $this->cacheReturnTypes(); - $urlType = $scope->getType($functionCall->getArgs()[0]->value); if (count($functionCall->getArgs()) > 1) { $componentType = $scope->getType($functionCall->getArgs()[1]->value); @@ -73,6 +72,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection, $componentType = new ConstantIntegerType(-1); } + $urlType = $scope->getType($functionCall->getArgs()[0]->value); if ($urlType instanceof ConstantStringType) { try { $result = @parse_url($urlType->getValue(), $componentType->getValue());