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) { if (null === $this->requestStack) {
throw new \RuntimeException('The "app.session" variable is not available.'); 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) public function getFlashes($types = null)
{ {
try { try {
$session = $this->getSession(); if (null === $session = $this->getSession()) {
if (null === $session) {
return []; return [];
} }
} catch (\RuntimeException $e) { } catch (\RuntimeException $e) {

View File

@ -70,7 +70,9 @@ class GlobalVariables
*/ */
public function getSession() 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. * 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()) { if (!$type = $parameter->getType()) {
return null; return null;

View File

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