Skip to content

Commit ff93b74

Browse files
committed
Improved Request::getContent() parameter detection
1 parent bb16f94 commit ff93b74

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Type/Symfony/RequestDynamicReturnTypeExtension.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ public function getTypeFromMethodCall(
3636
}
3737

3838
$argType = $scope->getType($methodCall->args[0]->value);
39-
if (!$argType instanceof ConstantBooleanType) {
40-
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
39+
$isTrueType = (new ConstantBooleanType(true))->isSuperTypeOf($argType);
40+
$isFalseType = (new ConstantBooleanType(false))->isSuperTypeOf($argType);
41+
$compareTypes = $isTrueType->compareTo($isFalseType);
42+
if ($compareTypes === $isTrueType) {
43+
return new ResourceType();
44+
}
45+
if ($compareTypes === $isFalseType) {
46+
return new StringType();
4147
}
4248

43-
return $argType->getValue() ? new ResourceType() : new StringType();
49+
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
4450
}
4551

4652
}

0 commit comments

Comments
 (0)