It seems like $requestStack->getCurrentRequest() can be null; however, getModifiedSince() does not accept null, maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of
other conditions, we strongly recommend to add an additional type check to your
code:
/** @return stdClass|null */functionmayReturnNull(){}functiondoesNotAcceptNull(stdClass$x){}// With potential error.functionwithoutCheck(){$x=mayReturnNull();doesNotAcceptNull($x);// Potential error here.}// Safe - Alternative 1functionwithCheck1(){$x=mayReturnNull();if(!$xinstanceofstdClass){thrownew\LogicException('$x must be defined.');}doesNotAcceptNull($x);}// Safe - Alternative 2functionwithCheck2(){$x=mayReturnNull();if($xinstanceofstdClass){doesNotAcceptNull($x);}}
Loading history...
19
7
}
20
21
/**
22
* @return \DateTime
23
*/
24
6
public function getValue(): \DateTime
25
{
26
6
return $this->value;
27
}
28
29
7
private function getModifiedSince(Request $request):\DateTime
30
{
31
7
if ($request->headers->has(self::HTTP_HEADER_NAME)) {
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: