migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Exposes some Symfony parameters and services as an "app" global variable.
@@ -39,14 +40,14 @@ class AppVariable
$this->requestStack = $requestStack;
}
public function setEnvironment($environment)
public function setEnvironment(string $environment)
{
$this->environment = $environment;
}
public function setDebug($debug)
public function setDebug(bool $debug)
{
$this->debug = (bool) $debug;
$this->debug = $debug;
}
/**
@@ -68,7 +69,7 @@ class AppVariable
/**
* Returns the current user.
*
* @return object|null
* @return UserInterface|null
*
* @see TokenInterface::getUser()
*/
@@ -84,13 +85,14 @@ class AppVariable
$user = $token->getUser();
// @deprecated since Symfony 5.4, $user will always be a UserInterface instance
return \is_object($user) ? $user : null;
}
/**
* Returns the current request.
*
* @return Request|null The HTTP request object
* @return Request|null
*/
public function getRequest()
{
@@ -104,21 +106,22 @@ class AppVariable
/**
* Returns the current session.
*
* @return Session|null The session
* @return Session|null
*/
public function getSession()
{
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;
}
/**
* Returns the current app environment.
*
* @return string The current environment string (e.g 'dev')
* @return string
*/
public function getEnvironment()
{
@@ -132,7 +135,7 @@ class AppVariable
/**
* Returns the current app debug mode.
*
* @return bool The current debug mode
* @return bool
*/
public function getDebug()
{
@@ -154,8 +157,7 @@ class AppVariable
public function getFlashes($types = null)
{
try {
$session = $this->getSession();
if (null === $session) {
if (null === $session = $this->getSession()) {
return [];
}
} catch (\RuntimeException $e) {