Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -11,6 +11,9 @@
namespace Symfony\Component\HttpFoundation;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* Request stack that controls the lifecycle of requests.
*
@@ -21,7 +24,7 @@ class RequestStack
/**
* @var Request[]
*/
private $requests = array();
private array $requests = [];
/**
* Pushes a Request on the stack.
@@ -41,39 +44,32 @@ class RequestStack
*
* This method should generally not be called directly as the stack
* management should be taken care of by the application itself.
*
* @return Request|null
*/
public function pop()
public function pop(): ?Request
{
if (!$this->requests) {
return;
return null;
}
return array_pop($this->requests);
}
/**
* @return Request|null
*/
public function getCurrentRequest()
public function getCurrentRequest(): ?Request
{
return end($this->requests) ?: null;
}
/**
* Gets the master Request.
* Gets the main request.
*
* Be warned that making your code aware of the master request
* Be warned that making your code aware of the main request
* might make it un-compatible with other features of your framework
* like ESI support.
*
* @return Request|null
*/
public function getMasterRequest()
public function getMainRequest(): ?Request
{
if (!$this->requests) {
return;
return null;
}
return $this->requests[0];
@@ -86,18 +82,26 @@ class RequestStack
* might make it un-compatible with other features of your framework
* like ESI support.
*
* If current Request is the master request, it returns null.
*
* @return Request|null
* If current Request is the main request, it returns null.
*/
public function getParentRequest()
public function getParentRequest(): ?Request
{
$pos = count($this->requests) - 2;
$pos = \count($this->requests) - 2;
if (!isset($this->requests[$pos])) {
return;
return $this->requests[$pos] ?? null;
}
/**
* Gets the current session.
*
* @throws SessionNotFoundException
*/
public function getSession(): SessionInterface
{
if ((null !== $request = end($this->requests) ?: null) && $request->hasSession()) {
return $request->getSession();
}
return $this->requests[$pos];
throw new SessionNotFoundException();
}
}