Skip to content

Commit 6241518

Browse files
Fix hasSession specifier
1 parent 45e2ae2 commit 6241518

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Type/Symfony/RequestTypeSpecifyingExtension.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,15 @@ public function specifyTypes(MethodReflection $methodReflection, MethodCall $nod
4646
{
4747
$classReflection = $this->broker->getClass(self::REQUEST_CLASS);
4848
$methodVariants = $classReflection->getNativeMethod(self::GET_METHOD_NAME)->getVariants();
49+
$returnType = ParametersAcceptorSelector::selectSingle($methodVariants)->getReturnType();
50+
51+
if (!TypeCombinator::containsNull($returnType)) {
52+
return new SpecifiedTypes();
53+
}
4954

5055
return $this->typeSpecifier->create(
5156
new MethodCall($node->var, self::GET_METHOD_NAME),
52-
TypeCombinator::removeNull(ParametersAcceptorSelector::selectSingle($methodVariants)->getReturnType()),
57+
TypeCombinator::removeNull($returnType),
5358
$context
5459
);
5560
}

tests/Type/Symfony/data/request_get_session.php

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@
1212
if ($request->hasSession()) {
1313
assertType(SessionInterface::class, $request->getSession());
1414
}
15+
16+
if (!$request->hasSession()) {
17+
assertType(SessionInterface::class, $request->getSession());
18+
}

0 commit comments

Comments
 (0)