This commit is contained in:
Nicolas Grekas 2019-08-20 16:36:26 +02:00
parent cfb218456c
commit 5ec6ff378b
4 changed files with 9 additions and 12 deletions

View File

@ -111,8 +111,9 @@ class AppVariable
if (null === $this->requestStack) {
throw new \RuntimeException('The "app.session" variable is not available.');
}
$request = $this->getRequest();
return ($request = $this->getRequest()) ? $request->getSession() : null;
return $request && $request->hasSession() ? $request->getSession() : null;
}
/**
@ -154,8 +155,7 @@ class AppVariable
public function getFlashes($types = null)
{
try {
$session = $this->getSession();
if (null === $session) {
if (null === $session = $this->getSession()) {
return [];
}
} catch (\RuntimeException $e) {

View File

@ -70,7 +70,9 @@ class GlobalVariables
*/
public function getSession()
{
return ($request = $this->getRequest()) ? $request->getSession() : null;
$request = $this->getRequest();
return $request && $request->hasSession() ? $request->getSession() : null;
}
/**

View File

@ -42,10 +42,8 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
/**
* Returns an associated type to the given parameter if available.
*
* @return string|null
*/
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function): ?string
{
if (!$type = $parameter->getType()) {
return null;

View File

@ -242,12 +242,9 @@ class Profiler implements ResetInterface
return $this->collectors[$name];
}
/**
* @return int|null
*/
private function getTimestamp($value)
private function getTimestamp(?string $value): ?int
{
if (null === $value || '' == $value) {
if (null === $value || '' === $value) {
return null;
}