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,10 +11,11 @@
namespace Symfony\Component\HttpKernel\Fragment;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Renders a URI that represents a resource fragment.
@@ -28,18 +29,15 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference;
*/
class FragmentHandler
{
private $debug;
private $renderers = array();
private bool $debug;
private array $renderers = [];
private $requestStack;
/**
* Constructor.
*
* @param RequestStack $requestStack The Request stack that controls the lifecycle of requests
* @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances
* @param bool $debug Whether the debug mode is enabled or not
* @param FragmentRendererInterface[] $renderers An array of FragmentRendererInterface instances
* @param bool $debug Whether the debug mode is enabled or not
*/
public function __construct(RequestStack $requestStack, array $renderers = array(), $debug = false)
public function __construct(RequestStack $requestStack, array $renderers = [], bool $debug = false)
{
$this->requestStack = $requestStack;
foreach ($renderers as $renderer) {
@@ -50,8 +48,6 @@ class FragmentHandler
/**
* Adds a renderer.
*
* @param FragmentRendererInterface $renderer A FragmentRendererInterface instance
*/
public function addRenderer(FragmentRendererInterface $renderer)
{
@@ -65,16 +61,10 @@ class FragmentHandler
*
* * ignore_errors: true to return an empty string in case of an error
*
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param string $renderer The renderer name
* @param array $options An array of options
*
* @return string|null The Response content or null when the Response is streamed
*
* @throws \InvalidArgumentException when the renderer does not exist
* @throws \LogicException when no master request is being handled
* @throws \LogicException when no main request is being handled
*/
public function render($uri, $renderer = 'inline', array $options = array())
public function render(string|ControllerReference $uri, string $renderer = 'inline', array $options = []): ?string
{
if (!isset($options['ignore_errors'])) {
$options['ignore_errors'] = !$this->debug;
@@ -97,16 +87,15 @@ class FragmentHandler
* When the Response is a StreamedResponse, the content is streamed immediately
* instead of being returned.
*
* @param Response $response A Response instance
*
* @return string|null The Response content or null when the Response is streamed
*
* @throws \RuntimeException when the Response is not successful
*/
protected function deliver(Response $response)
protected function deliver(Response $response): ?string
{
if (!$response->isSuccessful()) {
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requestStack->getCurrentRequest()->getUri(), $response->getStatusCode()));
$responseStatusCode = $response->getStatusCode();
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %d).', $this->requestStack->getCurrentRequest()->getUri(), $responseStatusCode), 0, new HttpException($responseStatusCode));
}
if (!$response instanceof StreamedResponse) {
@@ -114,5 +103,7 @@ class FragmentHandler
}
$response->sendContent();
return null;
}
}