composer update
This commit is contained in:
3
vendor/symfony/http-kernel/.gitattributes
vendored
Normal file
3
vendor/symfony/http-kernel/.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/Tests export-ignore
|
||||
/phpunit.xml.dist export-ignore
|
||||
/.gitignore export-ignore
|
||||
5
vendor/symfony/http-kernel/.gitignore
vendored
5
vendor/symfony/http-kernel/.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
Tests/Fixtures/cache/
|
||||
Tests/Fixtures/logs/
|
||||
15
vendor/symfony/http-kernel/Bundle/Bundle.php
vendored
15
vendor/symfony/http-kernel/Bundle/Bundle.php
vendored
@@ -18,8 +18,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
|
||||
/**
|
||||
* An implementation of BundleInterface that adds a few conventions
|
||||
* for DependencyInjection extensions and Console commands.
|
||||
* An implementation of BundleInterface that adds a few conventions for DependencyInjection extensions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -87,9 +86,7 @@ abstract class Bundle implements BundleInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->extension) {
|
||||
return $this->extension;
|
||||
}
|
||||
return $this->extension ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,10 +116,8 @@ abstract class Bundle implements BundleInterface
|
||||
|
||||
/**
|
||||
* Returns the bundle name (the class short name).
|
||||
*
|
||||
* @return string The Bundle name
|
||||
*/
|
||||
final public function getName()
|
||||
final public function getName(): string
|
||||
{
|
||||
if (null === $this->name) {
|
||||
$this->parseClassName();
|
||||
@@ -154,9 +149,7 @@ abstract class Bundle implements BundleInterface
|
||||
*/
|
||||
protected function createContainerExtension()
|
||||
{
|
||||
if (class_exists($class = $this->getContainerExtensionClass())) {
|
||||
return new $class();
|
||||
}
|
||||
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
|
||||
}
|
||||
|
||||
private function parseClassName()
|
||||
|
||||
27
vendor/symfony/http-kernel/CHANGELOG.md
vendored
27
vendor/symfony/http-kernel/CHANGELOG.md
vendored
@@ -1,6 +1,29 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* The `DebugHandlersListener` class has been marked as `final`
|
||||
* Added new Bundle directory convention consistent with standard skeletons
|
||||
* Deprecated the second and third argument of `KernelInterface::locateResource`
|
||||
* Deprecated the second and third argument of `FileLocator::__construct`
|
||||
* Deprecated loading resources from `%kernel.root_dir%/Resources` and `%kernel.root_dir%` as
|
||||
fallback directories. Resources like service definitions are usually loaded relative to the
|
||||
current directory or with a glob pattern. The fallback directories have never been advocated
|
||||
so you likely do not use those in any app based on the SF Standard or Flex edition.
|
||||
* Marked all dispatched event classes as `@final`
|
||||
* Added `ErrorController` to enable the preview and error rendering mechanism
|
||||
* Getting the container from a non-booted kernel is deprecated.
|
||||
* Marked the `AjaxDataCollector`, `ConfigDataCollector`, `EventDataCollector`,
|
||||
`ExceptionDataCollector`, `LoggerDataCollector`, `MemoryDataCollector`,
|
||||
`RequestDataCollector` and `TimeDataCollector` classes as `@final`.
|
||||
* Marked the `RouterDataCollector::collect()` method as `@final`.
|
||||
* The `DataCollectorInterface::collect()` and `Profiler::collect()` methods third parameter signature
|
||||
will be `\Throwable $exception = null` instead of `\Exception $exception = null` in Symfony 5.0.
|
||||
* Deprecated methods `ExceptionEvent::get/setException()`, use `get/setThrowable()` instead
|
||||
* Deprecated class `ExceptionListener`, use `ErrorListener` instead
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
@@ -31,8 +54,8 @@ CHANGELOG
|
||||
|
||||
* deprecated `KernelInterface::getRootDir()` and the `kernel.root_dir` parameter
|
||||
* deprecated `KernelInterface::getName()` and the `kernel.name` parameter
|
||||
* deprecated the first and second constructor argument of `ConfigDataCollector`
|
||||
* deprecated `ConfigDataCollector::getApplicationName()`
|
||||
* deprecated the first and second constructor argument of `ConfigDataCollector`
|
||||
* deprecated `ConfigDataCollector::getApplicationName()`
|
||||
* deprecated `ConfigDataCollector::getApplicationVersion()`
|
||||
|
||||
4.1.0
|
||||
|
||||
@@ -50,10 +50,9 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
if ($this->debug) {
|
||||
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
$collectedLogs = [];
|
||||
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
|
||||
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
|
||||
}
|
||||
@@ -61,7 +60,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
if (isset($collectedLogs[$message])) {
|
||||
++$collectedLogs[$message]['count'];
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
@@ -81,6 +80,8 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
'trace' => $backtrace,
|
||||
'count' => 1,
|
||||
];
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,7 +97,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
$warmer->warmUp($cacheDir);
|
||||
}
|
||||
} finally {
|
||||
if ($this->debug && true !== $previousHandler) {
|
||||
if ($collectDeprecations) {
|
||||
restore_error_handler();
|
||||
|
||||
if (file_exists($this->deprecationLogsFilepath)) {
|
||||
@@ -114,7 +115,7 @@ class CacheWarmerAggregate implements CacheWarmerInterface
|
||||
*
|
||||
* @return bool always false
|
||||
*/
|
||||
public function isOptional()
|
||||
public function isOptional(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
10
vendor/symfony/http-kernel/Client.php
vendored
10
vendor/symfony/http-kernel/Client.php
vendored
@@ -23,6 +23,9 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
/**
|
||||
* Client simulates a browser and makes requests to an HttpKernel instance.
|
||||
*
|
||||
* @method Request getRequest() A Request instance
|
||||
* @method Response getResponse() A Response instance
|
||||
*
|
||||
* @deprecated since Symfony 4.3, use HttpKernelBrowser instead.
|
||||
*/
|
||||
class Client extends AbstractBrowser
|
||||
@@ -31,10 +34,7 @@ class Client extends AbstractBrowser
|
||||
private $catchExceptions = true;
|
||||
|
||||
/**
|
||||
* @param HttpKernelInterface $kernel An HttpKernel instance
|
||||
* @param array $server The server parameters (equivalent of $_SERVER)
|
||||
* @param History $history A History instance to store the browser history
|
||||
* @param CookieJar $cookieJar A CookieJar instance to store the cookies
|
||||
* @param array $server The server parameters (equivalent of $_SERVER)
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $kernel, array $server = [], History $history = null, CookieJar $cookieJar = null)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ class Client extends AbstractBrowser
|
||||
foreach (get_declared_classes() as $class) {
|
||||
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
|
||||
$r = new \ReflectionClass($class);
|
||||
$file = \dirname(\dirname($r->getFileName())).'/autoload.php';
|
||||
$file = \dirname($r->getFileName(), 2).'/autoload.php';
|
||||
if (file_exists($file)) {
|
||||
$requires .= 'require_once '.var_export($file, true).";\n";
|
||||
}
|
||||
|
||||
@@ -22,19 +22,28 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
||||
class FileLocator extends BaseFileLocator
|
||||
{
|
||||
private $kernel;
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @param KernelInterface $kernel A KernelInterface instance
|
||||
* @param string|null $path The path the global resource directory
|
||||
* @param array $paths An array of paths where to look for resources
|
||||
* @deprecated since Symfony 4.4
|
||||
*/
|
||||
public function __construct(KernelInterface $kernel, string $path = null, array $paths = [])
|
||||
private $path;
|
||||
|
||||
public function __construct(KernelInterface $kernel/*, string $path = null, array $paths = [], bool $triggerDeprecation = true*/)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
if (null !== $path) {
|
||||
$this->path = $path;
|
||||
$paths[] = $path;
|
||||
|
||||
if (2 <= \func_num_args()) {
|
||||
$this->path = func_get_arg(1);
|
||||
$paths = 3 <= \func_num_args() ? func_get_arg(2) : [];
|
||||
if (null !== $this->path) {
|
||||
$paths[] = $this->path;
|
||||
}
|
||||
|
||||
if (4 !== \func_num_args() || func_get_arg(3)) {
|
||||
@trigger_error(sprintf('Passing more than one argument to %s is deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
} else {
|
||||
$paths = [];
|
||||
}
|
||||
|
||||
parent::__construct($paths);
|
||||
@@ -46,9 +55,32 @@ class FileLocator extends BaseFileLocator
|
||||
public function locate($file, $currentPath = null, $first = true)
|
||||
{
|
||||
if (isset($file[0]) && '@' === $file[0]) {
|
||||
return $this->kernel->locateResource($file, $this->path, $first);
|
||||
return $this->kernel->locateResource($file, $this->path, $first, false);
|
||||
}
|
||||
|
||||
return parent::locate($file, $currentPath, $first);
|
||||
$locations = parent::locate($file, $currentPath, $first);
|
||||
|
||||
if (isset($file[0]) && !(
|
||||
'/' === $file[0] || '\\' === $file[0]
|
||||
|| (\strlen($file) > 3 && ctype_alpha($file[0]) && ':' === $file[1] && ('\\' === $file[2] || '/' === $file[2]))
|
||||
|| null !== parse_url($file, PHP_URL_SCHEME)
|
||||
)) {
|
||||
// no need to trigger deprecations when the loaded file is given as absolute path
|
||||
foreach ($this->paths as $deprecatedPath) {
|
||||
if (\is_array($locations)) {
|
||||
foreach ($locations as $location) {
|
||||
if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) {
|
||||
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (0 === strpos($locations, $deprecatedPath) && (null === $currentPath || false === strpos($locations, $currentPath))) {
|
||||
@trigger_error(sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath), E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $locations;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArguments(Request $request, $controller)
|
||||
public function getArguments(Request $request, $controller): array
|
||||
{
|
||||
$arguments = [];
|
||||
|
||||
@@ -55,12 +55,14 @@ final class ArgumentResolver implements ArgumentResolverInterface
|
||||
|
||||
$resolved = $resolver->resolve($request, $metadata);
|
||||
|
||||
if (!$resolved instanceof \Generator) {
|
||||
throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver)));
|
||||
$atLeastOne = false;
|
||||
foreach ($resolved as $append) {
|
||||
$atLeastOne = true;
|
||||
$arguments[] = $append;
|
||||
}
|
||||
|
||||
foreach ($resolved as $append) {
|
||||
$arguments[] = $append;
|
||||
if (!$atLeastOne) {
|
||||
throw new \InvalidArgumentException(sprintf('%s::resolve() must yield at least one value.', \get_class($resolver)));
|
||||
}
|
||||
|
||||
// continue to the next controller argument
|
||||
|
||||
@@ -25,7 +25,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
return $argument->hasDefaultValue() || (null !== $argument->getType() && $argument->isNullable() && !$argument->isVariadic());
|
||||
}
|
||||
@@ -33,7 +33,7 @@ final class DefaultValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
yield $argument->hasDefaultValue() ? $argument->getDefaultValue() : null;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ final class NotTaggedControllerValueResolver implements ArgumentValueResolverInt
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
$controller = $request->attributes->get('_controller');
|
||||
|
||||
@@ -58,7 +58,7 @@ final class NotTaggedControllerValueResolver implements ArgumentValueResolverInt
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
if (\is_array($controller = $request->attributes->get('_controller'))) {
|
||||
$controller = $controller[0].'::'.$controller[1];
|
||||
|
||||
@@ -25,7 +25,7 @@ final class RequestAttributeValueResolver implements ArgumentValueResolverInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
return !$argument->isVariadic() && $request->attributes->has($argument->getName());
|
||||
}
|
||||
@@ -33,7 +33,7 @@ final class RequestAttributeValueResolver implements ArgumentValueResolverInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
yield $request->attributes->get($argument->getName());
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ final class RequestValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
return Request::class === $argument->getType() || is_subclass_of($argument->getType(), Request::class);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ final class RequestValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
yield $request;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
$controller = $request->attributes->get('_controller');
|
||||
|
||||
@@ -58,7 +58,7 @@ final class ServiceValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
if (\is_array($controller = $request->attributes->get('_controller'))) {
|
||||
$controller = $controller[0].'::'.$controller[1];
|
||||
|
||||
@@ -26,7 +26,7 @@ final class SessionValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
if (!$request->hasSession()) {
|
||||
return false;
|
||||
@@ -43,7 +43,7 @@ final class SessionValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
yield $request->getSession();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument)
|
||||
public function supports(Request $request, ArgumentMetadata $argument): bool
|
||||
{
|
||||
return $argument->isVariadic() && $request->attributes->has($argument->getName());
|
||||
}
|
||||
@@ -33,7 +33,7 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument)
|
||||
public function resolve(Request $request, ArgumentMetadata $argument): iterable
|
||||
{
|
||||
$values = $request->attributes->get($argument->getName());
|
||||
|
||||
@@ -41,8 +41,6 @@ final class VariadicValueResolver implements ArgumentValueResolverInterface
|
||||
throw new \InvalidArgumentException(sprintf('The action argument "...$%1$s" is required to be an array, the request attribute "%1$s" contains a type of "%2$s" instead.', $argument->getName(), \gettype($values)));
|
||||
}
|
||||
|
||||
foreach ($values as $value) {
|
||||
yield $value;
|
||||
}
|
||||
yield from $values;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ interface ArgumentResolverInterface
|
||||
/**
|
||||
* Returns the arguments to pass to the controller.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param callable $controller
|
||||
*
|
||||
* @return array An array of arguments to pass to the controller
|
||||
|
||||
@@ -24,9 +24,6 @@ interface ArgumentValueResolverInterface
|
||||
/**
|
||||
* Whether this resolver can resolve the value for the given ArgumentMetadata.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param ArgumentMetadata $argument
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function supports(Request $request, ArgumentMetadata $argument);
|
||||
@@ -34,10 +31,7 @@ interface ArgumentValueResolverInterface
|
||||
/**
|
||||
* Returns the possible value(s).
|
||||
*
|
||||
* @param Request $request
|
||||
* @param ArgumentMetadata $argument
|
||||
*
|
||||
* @return \Generator
|
||||
* @return iterable
|
||||
*/
|
||||
public function resolve(Request $request, ArgumentMetadata $argument);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ class ContainerControllerResolver extends ControllerResolver
|
||||
*/
|
||||
protected function instantiateController($class)
|
||||
{
|
||||
$class = ltrim($class, '\\');
|
||||
|
||||
if ($this->container->has($class)) {
|
||||
return $this->container->get($class);
|
||||
}
|
||||
@@ -59,7 +61,7 @@ class ContainerControllerResolver extends ControllerResolver
|
||||
$this->throwExceptionIfControllerWasRemoved($class, $e);
|
||||
|
||||
if ($e instanceof \ArgumentCountError) {
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define such a service?', $class), 0, $e);
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class', $class), 0, $e);
|
||||
|
||||
@@ -82,7 +82,11 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
return $controller;
|
||||
}
|
||||
|
||||
$callable = $this->createController($controller);
|
||||
try {
|
||||
$callable = $this->createController($controller);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $e->getMessage()));
|
||||
}
|
||||
|
||||
if (!\is_callable($callable)) {
|
||||
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable. %s', $request->getPathInfo(), $this->getControllerError($callable)));
|
||||
@@ -97,17 +101,25 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
* @param string $controller A Controller string
|
||||
*
|
||||
* @return callable A PHP callable
|
||||
*
|
||||
* @throws \InvalidArgumentException When the controller cannot be created
|
||||
*/
|
||||
protected function createController($controller)
|
||||
{
|
||||
if (false === strpos($controller, '::')) {
|
||||
return $this->instantiateController($controller);
|
||||
$controller = $this->instantiateController($controller);
|
||||
|
||||
if (!\is_callable($controller)) {
|
||||
throw new \InvalidArgumentException($this->getControllerError($controller));
|
||||
}
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
list($class, $method) = explode('::', $controller, 2);
|
||||
|
||||
try {
|
||||
return [$this->instantiateController($class), $method];
|
||||
$controller = [$this->instantiateController($class), $method];
|
||||
} catch (\Error | \LogicException $e) {
|
||||
try {
|
||||
if ((new \ReflectionMethod($class, $method))->isStatic()) {
|
||||
@@ -119,6 +131,12 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!\is_callable($controller)) {
|
||||
throw new \InvalidArgumentException($this->getControllerError($controller));
|
||||
}
|
||||
|
||||
return $controller;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +151,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
return new $class();
|
||||
}
|
||||
|
||||
private function getControllerError($callable)
|
||||
private function getControllerError($callable): string
|
||||
{
|
||||
if (\is_string($callable)) {
|
||||
if (false !== strpos($callable, '::')) {
|
||||
@@ -195,7 +213,7 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
return $message;
|
||||
}
|
||||
|
||||
private function getClassMethodsWithoutMagicMethods($classOrObject)
|
||||
private function getClassMethodsWithoutMagicMethods($classOrObject): array
|
||||
{
|
||||
$methods = get_class_methods($classOrObject);
|
||||
|
||||
|
||||
62
vendor/symfony/http-kernel/Controller/ErrorController.php
vendored
Normal file
62
vendor/symfony/http-kernel/Controller/ErrorController.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Controller;
|
||||
|
||||
use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* Renders error or exception pages from a given FlattenException.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
* @author Matthias Pigulla <mp@webfactory.de>
|
||||
*/
|
||||
class ErrorController
|
||||
{
|
||||
private $kernel;
|
||||
private $controller;
|
||||
private $errorRenderer;
|
||||
|
||||
public function __construct(HttpKernelInterface $kernel, $controller, ErrorRendererInterface $errorRenderer)
|
||||
{
|
||||
$this->kernel = $kernel;
|
||||
$this->controller = $controller;
|
||||
$this->errorRenderer = $errorRenderer;
|
||||
}
|
||||
|
||||
public function __invoke(\Throwable $exception): Response
|
||||
{
|
||||
$exception = $this->errorRenderer->render($exception);
|
||||
|
||||
return new Response($exception->getAsString(), $exception->getStatusCode(), $exception->getHeaders());
|
||||
}
|
||||
|
||||
public function preview(Request $request, int $code): Response
|
||||
{
|
||||
/*
|
||||
* This Request mimics the parameters set by
|
||||
* \Symfony\Component\HttpKernel\EventListener\ErrorListener::duplicateRequest, with
|
||||
* the additional "showException" flag.
|
||||
*/
|
||||
$subRequest = $request->duplicate(null, null, [
|
||||
'_controller' => $this->controller,
|
||||
'exception' => new HttpException($code, 'This is a sample exception.'),
|
||||
'logger' => null,
|
||||
'showException' => false,
|
||||
]);
|
||||
|
||||
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class ArgumentMetadata
|
||||
*
|
||||
* The type is the PHP class in 5.5+ and additionally the basic type in PHP 7.0+.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createArgumentMetadata($controller)
|
||||
public function createArgumentMetadata($controller): array
|
||||
{
|
||||
$arguments = [];
|
||||
|
||||
@@ -42,30 +42,24 @@ final class ArgumentMetadataFactory implements ArgumentMetadataFactoryInterface
|
||||
|
||||
/**
|
||||
* Returns an associated type to the given parameter if available.
|
||||
*
|
||||
* @param \ReflectionParameter $parameter
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function)
|
||||
private function getType(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $function): ?string
|
||||
{
|
||||
if (!$type = $parameter->getType()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
$name = $type->getName();
|
||||
$lcName = strtolower($name);
|
||||
|
||||
if ('self' !== $lcName && 'parent' !== $lcName) {
|
||||
return $name;
|
||||
}
|
||||
if (!$function instanceof \ReflectionMethod) {
|
||||
return;
|
||||
}
|
||||
if ('self' === $lcName) {
|
||||
return $function->getDeclaringClass()->name;
|
||||
}
|
||||
if ($parent = $function->getDeclaringClass()->getParentClass()) {
|
||||
return $parent->name;
|
||||
if ($function instanceof \ReflectionMethod) {
|
||||
$lcName = strtolower($name);
|
||||
switch ($lcName) {
|
||||
case 'self':
|
||||
return $function->getDeclaringClass()->name;
|
||||
case 'parent':
|
||||
return ($parent = $function->getDeclaringClass()->getParentClass()) ? $parent->name : null;
|
||||
}
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,17 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* AjaxDataCollector.
|
||||
*
|
||||
* @author Bart van den Burg <bart@burgov.nl>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class AjaxDataCollector extends DataCollector
|
||||
{
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
// all collecting is done client side
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\VarDumper\Caster\LinkStub;
|
||||
use Symfony\Component\VarDumper\Caster\ClassStub;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
@@ -28,7 +30,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
private $kernel;
|
||||
private $name;
|
||||
private $version;
|
||||
private $hasVarDumper;
|
||||
|
||||
public function __construct(string $name = null, string $version = null)
|
||||
{
|
||||
@@ -41,7 +42,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
$this->name = $name;
|
||||
$this->version = $version;
|
||||
$this->hasVarDumper = class_exists(LinkStub::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +54,10 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$this->data = [
|
||||
'app_name' => $this->name,
|
||||
@@ -78,13 +80,14 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
if (isset($this->kernel)) {
|
||||
foreach ($this->kernel->getBundles() as $name => $bundle) {
|
||||
$this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundle->getPath()) : $bundle->getPath();
|
||||
$this->data['bundles'][$name] = new ClassStub(\get_class($bundle));
|
||||
}
|
||||
|
||||
$this->data['symfony_state'] = $this->determineSymfonyState();
|
||||
$this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
|
||||
$eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE);
|
||||
$eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE);
|
||||
$this->data['symfony_lts'] = 4 === Kernel::MINOR_VERSION;
|
||||
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
|
||||
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
|
||||
$this->data['symfony_eom'] = $eom->format('F Y');
|
||||
$this->data['symfony_eol'] = $eol->format('F Y');
|
||||
}
|
||||
@@ -131,7 +134,7 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
/**
|
||||
* Gets the token.
|
||||
*
|
||||
* @return string The token
|
||||
* @return string|null The token
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
@@ -169,6 +172,14 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $this->data['symfony_minor_version'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the current Symfony version is a Long-Term Support one.
|
||||
*/
|
||||
public function isSymfonyLts(): bool
|
||||
{
|
||||
return $this->data['symfony_lts'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the human redable date when this Symfony version ends its
|
||||
* maintenance period.
|
||||
@@ -327,11 +338,11 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
*
|
||||
* @return string One of: dev, stable, eom, eol
|
||||
*/
|
||||
private function determineSymfonyState()
|
||||
private function determineSymfonyState(): string
|
||||
{
|
||||
$now = new \DateTime();
|
||||
$eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
|
||||
$eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE)->modify('last day of this month');
|
||||
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
|
||||
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->modify('last day of this month');
|
||||
|
||||
if ($now > $eol) {
|
||||
$versionState = 'eol';
|
||||
|
||||
@@ -28,6 +28,9 @@ use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
*/
|
||||
abstract class DataCollector implements DataCollectorInterface
|
||||
{
|
||||
/**
|
||||
* @var array|Data
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
@@ -74,9 +77,6 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
return $var;
|
||||
}
|
||||
if (null === $this->cloner) {
|
||||
if (!class_exists(CutStub::class)) {
|
||||
throw new \LogicException(sprintf('The VarDumper component is needed for the %s() method. Install symfony/var-dumper version 3.4 or above.', __METHOD__));
|
||||
}
|
||||
$this->cloner = new VarCloner();
|
||||
$this->cloner->setMaxItems(-1);
|
||||
$this->cloner->addCasters($this->getCasters());
|
||||
@@ -102,15 +102,14 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
|
||||
return $a;
|
||||
},
|
||||
];
|
||||
|
||||
if (method_exists(ReflectionCaster::class, 'unsetClosureFileInfo')) {
|
||||
$casters += ReflectionCaster::UNSET_CLOSURE_FILE_INFO;
|
||||
}
|
||||
] + ReflectionCaster::UNSET_CLOSURE_FILE_INFO;
|
||||
|
||||
return $casters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
|
||||
|
||||
@@ -24,8 +24,10 @@ interface DataCollectorInterface extends ResetInterface
|
||||
{
|
||||
/**
|
||||
* Collects data for the given Request and Response.
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null);
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/);
|
||||
|
||||
/**
|
||||
* Returns the name of the collector.
|
||||
|
||||
@@ -98,7 +98,12 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
@@ -148,7 +153,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
@@ -256,7 +261,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function doDump(DataDumperInterface $dumper, $data, $name, $file, $line)
|
||||
private function doDump(DataDumperInterface $dumper, $data, string $name, string $file, int $line)
|
||||
{
|
||||
if ($dumper instanceof CliDumper) {
|
||||
$contextDumper = function ($name, $file, $line, $fmt) {
|
||||
|
||||
@@ -23,6 +23,8 @@ use Symfony\Contracts\Service\ResetInterface;
|
||||
* EventDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class EventDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
@@ -38,8 +40,10 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
|
||||
$this->data = [
|
||||
@@ -99,8 +103,6 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
/**
|
||||
* Sets the not called listeners.
|
||||
*
|
||||
* @param array $listeners
|
||||
*
|
||||
* @see TraceableEventDispatcher
|
||||
*/
|
||||
public function setNotCalledListeners(array $listeners)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -19,17 +19,23 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* ExceptionDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ExceptionDataCollector extends DataCollector
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$exception = 2 < \func_num_args() ? func_get_arg(2) : null;
|
||||
|
||||
if (null !== $exception) {
|
||||
$this->data = [
|
||||
'exception' => FlattenException::create($exception),
|
||||
'exception' => FlattenException::createFromThrowable($exception),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -55,7 +61,7 @@ class ExceptionDataCollector extends DataCollector
|
||||
/**
|
||||
* Gets the exception.
|
||||
*
|
||||
* @return \Exception The exception
|
||||
* @return \Exception|FlattenException
|
||||
*/
|
||||
public function getException()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
|
||||
use Symfony\Component\Debug\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -21,6 +21,8 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
* LogDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
@@ -41,8 +43,10 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
|
||||
}
|
||||
@@ -75,11 +79,6 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
$this->currentRequest = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logs.
|
||||
*
|
||||
* @return array An array of logs
|
||||
*/
|
||||
public function getLogs()
|
||||
{
|
||||
return isset($this->data['logs']) ? $this->data['logs'] : [];
|
||||
@@ -123,7 +122,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return 'logger';
|
||||
}
|
||||
|
||||
private function getContainerDeprecationLogs()
|
||||
private function getContainerDeprecationLogs(): array
|
||||
{
|
||||
if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Deprecations.log')) {
|
||||
return [];
|
||||
@@ -149,7 +148,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $logs;
|
||||
}
|
||||
|
||||
private function getContainerCompilerLogs(?string $compilerLogsFilepath = null): array
|
||||
private function getContainerCompilerLogs(string $compilerLogsFilepath = null): array
|
||||
{
|
||||
if (!file_exists($compilerLogsFilepath)) {
|
||||
return [];
|
||||
@@ -168,7 +167,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $logs;
|
||||
}
|
||||
|
||||
private function sanitizeLogs($logs)
|
||||
private function sanitizeLogs(array $logs)
|
||||
{
|
||||
$sanitizedLogs = [];
|
||||
$silencedLogs = [];
|
||||
@@ -217,7 +216,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return array_values($sanitizedLogs);
|
||||
}
|
||||
|
||||
private function isSilencedOrDeprecationErrorLog(array $log)
|
||||
private function isSilencedOrDeprecationErrorLog(array $log): bool
|
||||
{
|
||||
if (!isset($log['context']['exception'])) {
|
||||
return false;
|
||||
@@ -236,7 +235,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return false;
|
||||
}
|
||||
|
||||
private function computeErrorsCount(array $containerDeprecationLogs)
|
||||
private function computeErrorsCount(array $containerDeprecationLogs): array
|
||||
{
|
||||
$silencedLogs = [];
|
||||
$count = [
|
||||
|
||||
@@ -18,6 +18,8 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
* MemoryDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
@@ -28,8 +30,10 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$this->updateMemoryUsage();
|
||||
}
|
||||
@@ -89,7 +93,7 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return 'memory';
|
||||
}
|
||||
|
||||
private function convertToBytes($memoryLimit)
|
||||
private function convertToBytes(string $memoryLimit): int
|
||||
{
|
||||
if ('-1' === $memoryLimit) {
|
||||
return -1;
|
||||
|
||||
@@ -22,6 +22,8 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class RequestDataCollector extends DataCollector implements EventSubscriberInterface, LateDataCollectorInterface
|
||||
{
|
||||
@@ -34,8 +36,10 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
// attributes are serialized and as they can be anything, they need to be converted to strings.
|
||||
$attributes = [];
|
||||
@@ -49,7 +53,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
}
|
||||
}
|
||||
|
||||
$content = null;
|
||||
try {
|
||||
$content = $request->getContent();
|
||||
} catch (\LogicException $e) {
|
||||
@@ -59,7 +62,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
|
||||
$sessionMetadata = [];
|
||||
$sessionAttributes = [];
|
||||
$session = null;
|
||||
$flashes = [];
|
||||
if ($request->hasSession()) {
|
||||
$session = $request->getSession();
|
||||
@@ -80,9 +82,9 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
}
|
||||
|
||||
$dotenvVars = [];
|
||||
foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) {
|
||||
if ('' !== $name && false !== $value = getenv($name)) {
|
||||
$dotenvVars[$name] = $value;
|
||||
foreach (explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? '') as $name) {
|
||||
if ('' !== $name && isset($_ENV[$name])) {
|
||||
$dotenvVars[$name] = $_ENV[$name];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,12 @@ class RouterDataCollector extends DataCollector
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
if ($response instanceof RedirectResponse) {
|
||||
$this->data['redirect'] = true;
|
||||
|
||||
@@ -15,11 +15,12 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||
|
||||
/**
|
||||
* TimeDataCollector.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
@@ -34,8 +35,10 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
if (null !== $this->kernel) {
|
||||
$startTime = $this->kernel->getStartTime();
|
||||
@@ -77,7 +80,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
/**
|
||||
* Sets the request events.
|
||||
*
|
||||
* @param array $events The request events
|
||||
* @param StopwatchEvent[] $events The request events
|
||||
*/
|
||||
public function setEvents(array $events)
|
||||
{
|
||||
@@ -91,7 +94,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
/**
|
||||
* Gets the request events.
|
||||
*
|
||||
* @return array The request events
|
||||
* @return StopwatchEvent[] The request events
|
||||
*/
|
||||
public function getEvents()
|
||||
{
|
||||
@@ -133,7 +136,7 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
/**
|
||||
* Gets the request time.
|
||||
*
|
||||
* @return int The time
|
||||
* @return float
|
||||
*/
|
||||
public function getStartTime()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\Debug;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Routing\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
/**
|
||||
@@ -80,7 +79,7 @@ class FileLinkFormatter
|
||||
{
|
||||
try {
|
||||
return $router->generate($routeName).$queryString;
|
||||
} catch (ExceptionInterface $e) {
|
||||
} catch (\Throwable $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -96,10 +95,12 @@ class FileLinkFormatter
|
||||
|
||||
if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
|
||||
return [
|
||||
$request->getSchemeAndHttpHost().$request->getBasePath().$this->urlFormat,
|
||||
$request->getSchemeAndHttpHost().$this->urlFormat,
|
||||
$this->baseDir.\DIRECTORY_SEPARATOR, '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ class TraceableEventDispatcher extends BaseTraceableEventDispatcher
|
||||
break;
|
||||
case KernelEvents::TERMINATE:
|
||||
$token = $event->getResponse()->headers->get('X-Debug-Token');
|
||||
if (null === $token) {
|
||||
break;
|
||||
}
|
||||
// There is a very special case when using built-in AppCache class as kernel wrapper, in the case
|
||||
// of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A].
|
||||
// In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID
|
||||
@@ -65,12 +68,18 @@ class TraceableEventDispatcher extends BaseTraceableEventDispatcher
|
||||
break;
|
||||
case KernelEvents::RESPONSE:
|
||||
$token = $event->getResponse()->headers->get('X-Debug-Token');
|
||||
if (null === $token) {
|
||||
break;
|
||||
}
|
||||
$this->stopwatch->stopSection($token);
|
||||
break;
|
||||
case KernelEvents::TERMINATE:
|
||||
// In the special case described in the `preDispatch` method above, the `$token` section
|
||||
// does not exist, then closing it throws an exception which must be caught.
|
||||
$token = $event->getResponse()->headers->get('X-Debug-Token');
|
||||
if (null === $token) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
$this->stopwatch->stopSection($token);
|
||||
} catch (\LogicException $e) {
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
namespace Symfony\Component\HttpKernel\DependencyInjection;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
/**
|
||||
@@ -54,10 +55,8 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
*
|
||||
* @param array $patterns The class patterns to expand
|
||||
* @param array $classes The existing classes to match against the patterns
|
||||
*
|
||||
* @return array A list of classes derived from the patterns
|
||||
*/
|
||||
private function expandClasses(array $patterns, array $classes)
|
||||
private function expandClasses(array $patterns, array $classes): array
|
||||
{
|
||||
$expanded = [];
|
||||
|
||||
@@ -83,7 +82,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return array_unique($expanded);
|
||||
}
|
||||
|
||||
private function getClassesInComposerClassMaps()
|
||||
private function getClassesInComposerClassMaps(): array
|
||||
{
|
||||
$classes = [];
|
||||
|
||||
@@ -92,7 +91,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($function[0] instanceof DebugClassLoader) {
|
||||
if ($function[0] instanceof DebugClassLoader || $function[0] instanceof LegacyDebugClassLoader) {
|
||||
$function = $function[0]->getClassLoader();
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return array_keys($classes);
|
||||
}
|
||||
|
||||
private function patternsToRegexps($patterns)
|
||||
private function patternsToRegexps(array $patterns): array
|
||||
{
|
||||
$regexps = [];
|
||||
|
||||
@@ -126,7 +125,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
return $regexps;
|
||||
}
|
||||
|
||||
private function matchAnyRegexps($class, $regexps)
|
||||
private function matchAnyRegexps(string $class, array $regexps): bool
|
||||
{
|
||||
$blacklisted = false !== strpos($class, 'Test');
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* controller.
|
||||
*
|
||||
* @author Christophe Coevoet <stof@notk.org>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ControllerArgumentsEvent extends FilterControllerArgumentsEvent
|
||||
{
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* Controllers should be callables.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ControllerEvent extends FilterControllerEvent
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* event.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ExceptionEvent extends GetResponseForExceptionEvent
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
/**
|
||||
* @deprecated since Symfony 4.3, use ControllerArgumentsEvent instead
|
||||
*/
|
||||
class FilterControllerArgumentsEvent extends ControllerEvent
|
||||
class FilterControllerArgumentsEvent extends FilterControllerEvent
|
||||
{
|
||||
private $arguments;
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* Triggered whenever a request is fully processed.
|
||||
*
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class FinishRequestEvent extends KernelEvent
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Event;
|
||||
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
@@ -19,45 +20,55 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
*/
|
||||
class GetResponseForExceptionEvent extends RequestEvent
|
||||
{
|
||||
/**
|
||||
* The exception object.
|
||||
*
|
||||
* @var \Exception
|
||||
*/
|
||||
private $throwable;
|
||||
private $exception;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $allowCustomResponseCode = false;
|
||||
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Exception $e)
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, int $requestType, \Throwable $e)
|
||||
{
|
||||
parent::__construct($kernel, $request, $requestType);
|
||||
|
||||
$this->setException($e);
|
||||
$this->setThrowable($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thrown exception.
|
||||
*
|
||||
* @return \Exception The thrown exception
|
||||
*/
|
||||
public function getException()
|
||||
public function getThrowable(): \Throwable
|
||||
{
|
||||
return $this->exception;
|
||||
return $this->throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the thrown exception.
|
||||
*
|
||||
* This exception will be thrown if no response is set in the event.
|
||||
*/
|
||||
public function setThrowable(\Throwable $exception): void
|
||||
{
|
||||
$this->exception = null;
|
||||
$this->throwable = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.4, use getThrowable instead
|
||||
*
|
||||
* @return \Exception The thrown exception
|
||||
*/
|
||||
public function getException()
|
||||
{
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use "getThrowable()" instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
return $this->exception ?? $this->exception = $this->throwable instanceof \Exception ? $this->throwable : new FatalThrowableError($this->throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.4, use setThrowable instead
|
||||
*
|
||||
* @param \Exception $exception The thrown exception
|
||||
*/
|
||||
public function setException(\Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.4, use "setThrowable()" instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
|
||||
$this->throwable = $this->exception = $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,10 +27,8 @@ class KernelEvent extends Event
|
||||
private $requestType;
|
||||
|
||||
/**
|
||||
* @param HttpKernelInterface $kernel The kernel in which this event was thrown
|
||||
* @param Request $request The request the kernel is currently processing
|
||||
* @param int $requestType The request type the kernel is currently processing; one of
|
||||
* HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST
|
||||
* @param int $requestType The request type the kernel is currently processing; one of
|
||||
* HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $kernel, Request $request, ?int $requestType)
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* browser.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ResponseEvent extends FilterResponseEvent
|
||||
{
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* will always return the value of `HttpKernelInterface::MASTER_REQUEST`.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class TerminateEvent extends PostResponseEvent
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* response is set.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ViewEvent extends GetResponseForControllerResultEvent
|
||||
{
|
||||
|
||||
@@ -85,6 +85,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
|
||||
if ($session instanceof Session ? $session->getUsageIndex() !== end($this->sessionUsageStack) : $session->isStarted()) {
|
||||
if ($autoCacheControl) {
|
||||
$response
|
||||
->setExpires(new \DateTime())
|
||||
->setPrivate()
|
||||
->setMaxAge(0)
|
||||
->headers->addCacheControlDirective('must-revalidate');
|
||||
@@ -106,7 +107,7 @@ abstract class AbstractSessionListener implements EventSubscriberInterface
|
||||
* the one above. But by saving the session before long-running things in the terminate event,
|
||||
* we ensure the session is not blocked longer than needed.
|
||||
* * When regenerating the session ID no locking is involved in PHPs session design. See
|
||||
* https://bugs.php.net/bug.php?id=61470 for a discussion. So in this case, the session must
|
||||
* https://bugs.php.net/61470 for a discussion. So in this case, the session must
|
||||
* be saved anyway before sending the headers with the new session ID. Otherwise session
|
||||
* data could get lost again for concurrent requests with the new ID. One result could be
|
||||
* that you get logged out after just logging in.
|
||||
|
||||
@@ -46,8 +46,7 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
// bootstrap the session
|
||||
$session = $this->getSession();
|
||||
if (!$session) {
|
||||
if (!$session = $this->getSession()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,11 @@ use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\ConsoleEvents;
|
||||
use Symfony\Component\Console\Event\ConsoleEvent;
|
||||
use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\ExceptionHandler;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\KernelEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
@@ -30,6 +27,8 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
* Configures errors and exceptions handlers.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class DebugHandlersListener implements EventSubscriberInterface
|
||||
{
|
||||
@@ -40,20 +39,18 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
private $scream;
|
||||
private $fileLinkFormat;
|
||||
private $scope;
|
||||
private $charset;
|
||||
private $firstCall = true;
|
||||
private $hasTerminatedWithException;
|
||||
|
||||
/**
|
||||
* @param callable|null $exceptionHandler A handler that will be called on Exception
|
||||
* @param LoggerInterface|null $logger A PSR-3 logger
|
||||
* @param callable|null $exceptionHandler A handler that must support \Throwable instances that will be called on Exception
|
||||
* @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
|
||||
* @param int|null $throwAt Thrown errors in a bit field of E_* constants, or null to keep the current value
|
||||
* @param bool $scream Enables/disables screaming mode, where even silenced errors are logged
|
||||
* @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files
|
||||
* @param bool $scope Enables/disables scoping mode
|
||||
*/
|
||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, string $charset = null)
|
||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true)
|
||||
{
|
||||
$this->exceptionHandler = $exceptionHandler;
|
||||
$this->logger = $logger;
|
||||
@@ -62,7 +59,6 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
$this->scream = $scream;
|
||||
$this->fileLinkFormat = $fileLinkFormat;
|
||||
$this->scope = $scope;
|
||||
$this->charset = $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,10 +107,11 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
if (method_exists($kernel = $event->getKernel(), 'terminateWithException')) {
|
||||
$request = $event->getRequest();
|
||||
$hasRun = &$this->hasTerminatedWithException;
|
||||
$this->exceptionHandler = static function (\Exception $e) use ($kernel, $request, &$hasRun) {
|
||||
$this->exceptionHandler = static function (\Throwable $e) use ($kernel, $request, &$hasRun) {
|
||||
if ($hasRun) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$hasRun = true;
|
||||
$kernel->terminateWithException($e, $request);
|
||||
};
|
||||
@@ -124,51 +121,27 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
if ($output instanceof ConsoleOutputInterface) {
|
||||
$output = $output->getErrorOutput();
|
||||
}
|
||||
$this->exceptionHandler = function ($e) use ($app, $output) {
|
||||
$app->renderException($e, $output);
|
||||
$this->exceptionHandler = static function (\Throwable $e) use ($app, $output) {
|
||||
if (method_exists($app, 'renderThrowable')) {
|
||||
$app->renderThrowable($e, $output);
|
||||
} else {
|
||||
if (!$e instanceof \Exception) {
|
||||
$e = new FatalThrowableError($e);
|
||||
}
|
||||
|
||||
$app->renderException($e, $output);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
if ($this->exceptionHandler) {
|
||||
if ($handler instanceof ErrorHandler) {
|
||||
$h = $handler->setExceptionHandler('var_dump');
|
||||
if (\is_array($h) && $h[0] instanceof ExceptionHandler) {
|
||||
$handler->setExceptionHandler($h);
|
||||
$handler = $h[0];
|
||||
} else {
|
||||
$handler->setExceptionHandler($this->exceptionHandler);
|
||||
}
|
||||
}
|
||||
if ($handler instanceof ExceptionHandler) {
|
||||
$handler->setHandler($this->exceptionHandler);
|
||||
if (null !== $this->fileLinkFormat) {
|
||||
$handler->setFileLinkFormat($this->fileLinkFormat);
|
||||
}
|
||||
$handler->setExceptionHandler($this->exceptionHandler);
|
||||
}
|
||||
$this->exceptionHandler = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$debug = $this->scream && $this->scope;
|
||||
$controller = function (Request $request) use ($debug) {
|
||||
$e = $request->attributes->get('exception');
|
||||
$handler = new ExceptionHandler($debug, $this->charset, $this->fileLinkFormat);
|
||||
|
||||
return new Response($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
|
||||
};
|
||||
|
||||
(new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
$events = [KernelEvents::REQUEST => ['configure', 2048]];
|
||||
@@ -177,8 +150,6 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||
$events[ConsoleEvents::COMMAND] = ['configure', 2048];
|
||||
}
|
||||
|
||||
$events[KernelEvents::EXCEPTION] = ['onKernelException', -2048];
|
||||
|
||||
return $events;
|
||||
}
|
||||
}
|
||||
|
||||
148
vendor/symfony/http-kernel/EventListener/ErrorListener.php
vendored
Normal file
148
vendor/symfony/http-kernel/EventListener/ErrorListener.php
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ErrorListener implements EventSubscriberInterface
|
||||
{
|
||||
protected $controller;
|
||||
protected $logger;
|
||||
protected $debug;
|
||||
|
||||
public function __construct($controller, LoggerInterface $logger = null, $debug = false)
|
||||
{
|
||||
$this->controller = $controller;
|
||||
$this->logger = $logger;
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
public function logKernelException(ExceptionEvent $event)
|
||||
{
|
||||
$e = FlattenException::createFromThrowable($event->getThrowable());
|
||||
|
||||
$this->logException($event->getThrowable(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()));
|
||||
}
|
||||
|
||||
public function onKernelException(ExceptionEvent $event, string $eventName = null, EventDispatcherInterface $eventDispatcher = null)
|
||||
{
|
||||
if (null === $this->controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
$exception = $event->getThrowable();
|
||||
$request = $this->duplicateRequest($exception, $event->getRequest());
|
||||
|
||||
try {
|
||||
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
$f = FlattenException::createFromThrowable($e);
|
||||
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
$prev = $e;
|
||||
do {
|
||||
if ($exception === $wrapper = $prev) {
|
||||
throw $e;
|
||||
}
|
||||
} while ($prev = $wrapper->getPrevious());
|
||||
|
||||
$prev = new \ReflectionProperty($wrapper instanceof \Exception ? \Exception::class : \Error::class, 'previous');
|
||||
$prev->setAccessible(true);
|
||||
$prev->setValue($wrapper, $exception);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$event->setResponse($response);
|
||||
|
||||
if ($this->debug && $eventDispatcher instanceof EventDispatcherInterface) {
|
||||
$cspRemovalListener = function ($event) use (&$cspRemovalListener, $eventDispatcher) {
|
||||
$event->getResponse()->headers->remove('Content-Security-Policy');
|
||||
$eventDispatcher->removeListener(KernelEvents::RESPONSE, $cspRemovalListener);
|
||||
};
|
||||
$eventDispatcher->addListener(KernelEvents::RESPONSE, $cspRemovalListener, -128);
|
||||
}
|
||||
}
|
||||
|
||||
public function onControllerArguments(ControllerArgumentsEvent $event)
|
||||
{
|
||||
$e = $event->getRequest()->attributes->get('exception');
|
||||
|
||||
if (!$e instanceof \Throwable || false === $k = array_search($e, $event->getArguments(), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = new \ReflectionFunction(\Closure::fromCallable($event->getController()));
|
||||
$r = $r->getParameters()[$k] ?? null;
|
||||
|
||||
if ($r && (!$r->hasType() || FlattenException::class === $r->getType()->getName())) {
|
||||
$arguments = $event->getArguments();
|
||||
$arguments[$k] = FlattenException::createFromThrowable($e);
|
||||
$event->setArguments($arguments);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
KernelEvents::CONTROLLER_ARGUMENTS => 'onControllerArguments',
|
||||
KernelEvents::EXCEPTION => [
|
||||
['logKernelException', 0],
|
||||
['onKernelException', -128],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an exception.
|
||||
*/
|
||||
protected function logException(\Throwable $exception, string $message): void
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
|
||||
$this->logger->critical($message, ['exception' => $exception]);
|
||||
} else {
|
||||
$this->logger->error($message, ['exception' => $exception]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the request for the exception.
|
||||
*/
|
||||
protected function duplicateRequest(\Throwable $exception, Request $request): Request
|
||||
{
|
||||
$attributes = [
|
||||
'_controller' => $this->controller,
|
||||
'exception' => $exception,
|
||||
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
||||
];
|
||||
$request = $request->duplicate(null, null, $attributes);
|
||||
$request->setMethod('GET');
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
@@ -12,21 +12,20 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
|
||||
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "ErrorListener" instead.', ExceptionListener::class), E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.3
|
||||
* @deprecated since Symfony 4.4, use ErrorListener instead
|
||||
*/
|
||||
class ExceptionListener implements EventSubscriberInterface
|
||||
{
|
||||
@@ -43,15 +42,11 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
|
||||
public function logKernelException(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
$e = FlattenException::create($event->getException());
|
||||
$e = FlattenException::createFromThrowable($event->getException());
|
||||
|
||||
$this->logException($event->getException(), sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $eventName
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
*/
|
||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if (null === $this->controller) {
|
||||
@@ -65,7 +60,7 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
try {
|
||||
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, false);
|
||||
} catch (\Exception $e) {
|
||||
$f = FlattenException::create($e);
|
||||
$f = FlattenException::createFromThrowable($e);
|
||||
|
||||
$this->logException($e, sprintf('Exception thrown when handling an exception (%s: %s at %s line %s)', $f->getClass(), $f->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
@@ -124,16 +119,13 @@ class ExceptionListener implements EventSubscriberInterface
|
||||
/**
|
||||
* Clones the request for the exception.
|
||||
*
|
||||
* @param \Exception $exception The thrown exception
|
||||
* @param Request $request The original request
|
||||
*
|
||||
* @return Request The cloned request
|
||||
*/
|
||||
protected function duplicateRequest(\Exception $exception, Request $request)
|
||||
{
|
||||
$attributes = [
|
||||
'_controller' => $this->controller,
|
||||
'exception' => FlattenException::create($exception),
|
||||
'exception' => FlattenException::createFromThrowable($exception),
|
||||
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
||||
];
|
||||
$request = $request->duplicate(null, null, $attributes);
|
||||
|
||||
@@ -37,8 +37,7 @@ class FragmentListener implements EventSubscriberInterface
|
||||
private $fragmentPath;
|
||||
|
||||
/**
|
||||
* @param UriSigner $signer A UriSigner instance
|
||||
* @param string $fragmentPath The path that triggers this listener
|
||||
* @param string $fragmentPath The path that triggers this listener
|
||||
*/
|
||||
public function __construct(UriSigner $signer, string $fragmentPath = '/_fragment')
|
||||
{
|
||||
@@ -79,7 +78,7 @@ class FragmentListener implements EventSubscriberInterface
|
||||
protected function validateRequest(Request $request)
|
||||
{
|
||||
// is the Request safe?
|
||||
if (!$request->isMethodSafe(false)) {
|
||||
if (!$request->isMethodSafe()) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ class LocaleAwareListener implements EventSubscriberInterface
|
||||
public function onKernelFinishRequest(FinishRequestEvent $event): void
|
||||
{
|
||||
if (null === $parentRequest = $this->requestStack->getParentRequest()) {
|
||||
$this->setLocale($event->getRequest()->getDefaultLocale());
|
||||
foreach ($this->localeAwareServices as $service) {
|
||||
$service->setLocale($event->getRequest()->getDefaultLocale());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +65,7 @@ class LocaleAwareListener implements EventSubscriberInterface
|
||||
];
|
||||
}
|
||||
|
||||
private function setLocale(string $locale, ?string $defaultLocale = null): void
|
||||
private function setLocale(string $locale, string $defaultLocale): void
|
||||
{
|
||||
foreach ($this->localeAwareServices as $service) {
|
||||
try {
|
||||
|
||||
@@ -33,11 +33,6 @@ class LocaleListener implements EventSubscriberInterface
|
||||
private $defaultLocale;
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param string $defaultLocale The default locale
|
||||
* @param RequestContextAwareInterface|null $router The router
|
||||
*/
|
||||
public function __construct(RequestStack $requestStack, string $defaultLocale = 'en', RequestContextAwareInterface $router = null)
|
||||
{
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
|
||||
@@ -39,11 +39,8 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
protected $parents;
|
||||
|
||||
/**
|
||||
* @param Profiler $profiler A Profiler instance
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param RequestMatcherInterface|null $matcher A RequestMatcher instance
|
||||
* @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise
|
||||
* @param bool $onlyMasterRequests True if the profiler only collects data when the request is a master request, false otherwise
|
||||
* @param bool $onlyException True if the profiler only collects data when an exception occurs, false otherwise
|
||||
* @param bool $onlyMasterRequests True if the profiler only collects data when the request is a master request, false otherwise
|
||||
*/
|
||||
public function __construct(Profiler $profiler, RequestStack $requestStack, RequestMatcherInterface $matcher = null, bool $onlyException = false, bool $onlyMasterRequests = false)
|
||||
{
|
||||
@@ -65,7 +62,7 @@ class ProfilerListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$this->exception = $event->getException();
|
||||
$this->exception = $event->getThrowable();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,12 +50,9 @@ class RouterListener implements EventSubscriberInterface
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
* @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher
|
||||
* @param RequestStack $requestStack A RequestStack instance
|
||||
* @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
|
||||
* @param LoggerInterface|null $logger The logger
|
||||
* @param UrlMatcherInterface|RequestMatcherInterface $matcher The Url or Request matcher
|
||||
* @param RequestContext|null $context The RequestContext (can be null when $matcher implements RequestContextAwareInterface)
|
||||
* @param string $projectDir
|
||||
* @param bool $debug
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
@@ -91,8 +88,6 @@ class RouterListener implements EventSubscriberInterface
|
||||
/**
|
||||
* After a sub-request is done, we need to reset the routing context to the parent request so that the URL generator
|
||||
* operates on the correct context again.
|
||||
*
|
||||
* @param FinishRequestEvent $event
|
||||
*/
|
||||
public function onKernelFinishRequest(FinishRequestEvent $event)
|
||||
{
|
||||
@@ -148,7 +143,7 @@ class RouterListener implements EventSubscriberInterface
|
||||
|
||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
if (!$this->debug || !($e = $event->getException()) instanceof NotFoundHttpException) {
|
||||
if (!$this->debug || !($e = $event->getThrowable()) instanceof NotFoundHttpException) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,14 +161,14 @@ class RouterListener implements EventSubscriberInterface
|
||||
];
|
||||
}
|
||||
|
||||
private function createWelcomeResponse()
|
||||
private function createWelcomeResponse(): Response
|
||||
{
|
||||
$version = Kernel::VERSION;
|
||||
$baseDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;
|
||||
$projectDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;
|
||||
$docVersion = substr(Kernel::VERSION, 0, 3);
|
||||
|
||||
ob_start();
|
||||
include __DIR__.'/../Resources/welcome.html.php';
|
||||
include \dirname(__DIR__).'/Resources/welcome.html.php';
|
||||
|
||||
return new Response(ob_get_clean(), Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ class SaveSessionListener implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$session = $event->getRequest()->getSession();
|
||||
if ($session && $session->isStarted()) {
|
||||
$request = $event->getRequest();
|
||||
if ($request->hasSession() && ($session = $request->getSession())->isStarted()) {
|
||||
$session->save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
|
||||
|
||||
/**
|
||||
@@ -32,10 +33,10 @@ class SessionListener extends AbstractSessionListener
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
protected function getSession()
|
||||
protected function getSession(): ?SessionInterface
|
||||
{
|
||||
if (!$this->container->has('session')) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->container->has('session_storage')
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpKernel\EventListener;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
/**
|
||||
* Sets the session in the request.
|
||||
@@ -30,10 +31,10 @@ class TestSessionListener extends AbstractTestSessionListener
|
||||
parent::__construct($sessionOptions);
|
||||
}
|
||||
|
||||
protected function getSession()
|
||||
protected function getSession(): ?SessionInterface
|
||||
{
|
||||
if (!$this->container->has('session')) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->container->get('session');
|
||||
|
||||
@@ -21,7 +21,6 @@ class AccessDeniedHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class BadRequestHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class ConflictHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class GoneHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Symfony\Component\HttpKernel\Exception;
|
||||
*
|
||||
* @author Kris Wallsmith <kris@symfony.com>
|
||||
*/
|
||||
interface HttpExceptionInterface
|
||||
interface HttpExceptionInterface extends \Throwable
|
||||
{
|
||||
/**
|
||||
* Returns the status code.
|
||||
|
||||
@@ -20,7 +20,6 @@ class LengthRequiredHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ class MethodNotAllowedHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(array $allow, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class NotAcceptableHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class NotFoundHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class PreconditionFailedHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@ class PreconditionRequiredHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ class ServiceUnavailableHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -23,7 +23,6 @@ class TooManyRequestsHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ class UnauthorizedHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $challenge, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class UnprocessableEntityHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ class UnsupportedMediaTypeHttpException extends HttpException
|
||||
* @param string $message The internal exception message
|
||||
* @param \Throwable $previous The previous exception
|
||||
* @param int $code The internal exception code
|
||||
* @param array $headers
|
||||
*/
|
||||
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
|
||||
{
|
||||
|
||||
@@ -32,9 +32,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
* The "fallback" strategy when surrogate is not available should always be an
|
||||
* instance of InlineFragmentRenderer.
|
||||
*
|
||||
* @param SurrogateInterface $surrogate An Surrogate instance
|
||||
* @param FragmentRendererInterface $inlineStrategy The inline strategy to use when the surrogate is not supported
|
||||
* @param UriSigner $signer
|
||||
*/
|
||||
public function __construct(SurrogateInterface $surrogate = null, FragmentRendererInterface $inlineStrategy, UriSigner $signer = null)
|
||||
{
|
||||
@@ -83,7 +81,7 @@ abstract class AbstractSurrogateFragmentRenderer extends RoutableFragmentRendere
|
||||
return new Response($tag);
|
||||
}
|
||||
|
||||
private function generateSignedFragmentUri($uri, Request $request): string
|
||||
private function generateSignedFragmentUri(ControllerReference $uri, Request $request): string
|
||||
{
|
||||
if (null === $this->signer) {
|
||||
throw new \LogicException('You must use a URI when using the ESI rendering strategy or set a URL signer.');
|
||||
|
||||
@@ -33,9 +33,8 @@ class FragmentHandler
|
||||
private $requestStack;
|
||||
|
||||
/**
|
||||
* @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 = [], bool $debug = false)
|
||||
{
|
||||
@@ -63,7 +62,6 @@ class FragmentHandler
|
||||
*
|
||||
* @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
|
||||
*
|
||||
@@ -108,5 +106,7 @@ class FragmentHandler
|
||||
}
|
||||
|
||||
$response->sendContent();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@ interface FragmentRendererInterface
|
||||
/**
|
||||
* Renders a URI and returns the Response content.
|
||||
*
|
||||
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
|
||||
* @param Request $request A Request instance
|
||||
* @param array $options An array of options
|
||||
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ use Symfony\Component\Templating\EngineInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Loader\ExistsLoaderInterface;
|
||||
use Twig\Loader\SourceContextLoaderInterface;
|
||||
|
||||
/**
|
||||
* Implements the Hinclude rendering strategy.
|
||||
@@ -34,9 +35,7 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
|
||||
/**
|
||||
* @param EngineInterface|Environment $templating An EngineInterface or a Twig instance
|
||||
* @param UriSigner $signer A UriSigner instance
|
||||
* @param string $globalDefaultTemplate The global default content (it can be a template name or the content)
|
||||
* @param string $charset
|
||||
*/
|
||||
public function __construct($templating = null, UriSigner $signer = null, string $globalDefaultTemplate = null, string $charset = 'utf-8')
|
||||
{
|
||||
@@ -52,6 +51,8 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
* @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function setTemplating($templating)
|
||||
{
|
||||
@@ -136,22 +137,23 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
||||
}
|
||||
|
||||
$loader = $this->templating->getLoader();
|
||||
if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
|
||||
return $loader->exists($template);
|
||||
}
|
||||
|
||||
try {
|
||||
if (method_exists($loader, 'getSourceContext')) {
|
||||
$loader->getSourceContext($template);
|
||||
} else {
|
||||
$loader->getSource($template);
|
||||
if (1 === Environment::MAJOR_VERSION && !$loader instanceof ExistsLoaderInterface) {
|
||||
try {
|
||||
if ($loader instanceof SourceContextLoaderInterface) {
|
||||
$loader->getSourceContext($template);
|
||||
} else {
|
||||
$loader->getSource($template);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (LoaderError $e) {
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (LoaderError $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $loader->exists($template);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -122,7 +122,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
static $setSession;
|
||||
|
||||
if (null === $setSession) {
|
||||
$setSession = \Closure::bind(function ($subRequest, $request) { $subRequest->session = $request->session; }, null, Request::class);
|
||||
$setSession = \Closure::bind(static function ($subRequest, $request) { $subRequest->session = $request->session; }, null, Request::class);
|
||||
}
|
||||
$setSession($subRequest, $request);
|
||||
|
||||
|
||||
@@ -39,10 +39,8 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
||||
/**
|
||||
* Generates a fragment URI for a given controller.
|
||||
*
|
||||
* @param ControllerReference $reference A ControllerReference instance
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $absolute Whether to generate an absolute URL or not
|
||||
* @param bool $strict Whether to allow non-scalar attributes or not
|
||||
* @param bool $absolute Whether to generate an absolute URL or not
|
||||
* @param bool $strict Whether to allow non-scalar attributes or not
|
||||
*
|
||||
* @return string A fragment URI
|
||||
*/
|
||||
@@ -77,7 +75,7 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
||||
return $request->getBaseUrl().$path;
|
||||
}
|
||||
|
||||
private function checkNonScalar($values)
|
||||
private function checkNonScalar(array $values)
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
if (\is_array($value)) {
|
||||
|
||||
@@ -109,6 +109,8 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Esi.php
vendored
@@ -111,5 +111,7 @@ class Esi extends AbstractSurrogate
|
||||
|
||||
// remove ESI/1.0 from the Surrogate-Control header
|
||||
$this->removeFromControl($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
'trace_header' => 'X-Symfony-Cache',
|
||||
], $options);
|
||||
|
||||
if (!isset($options['trace_level']) && $this->options['debug']) {
|
||||
$this->options['trace_level'] = 'full';
|
||||
if (!isset($options['trace_level'])) {
|
||||
$this->options['trace_level'] = $this->options['debug'] ? 'full' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
|
||||
$this->traces[$this->getTraceKey($request)] = [];
|
||||
|
||||
if (!$request->isMethodSafe(false)) {
|
||||
if (!$request->isMethodSafe()) {
|
||||
$response = $this->invalidate($request, $catch);
|
||||
} elseif ($request->headers->has('expect') || !$request->isMethodCacheable()) {
|
||||
$response = $this->pass($request, $catch);
|
||||
@@ -256,8 +256,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Forwards the Request to the backend without storing the Response in the cache.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -271,8 +270,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Invalidates non-safe methods (like POST, PUT, and DELETE).
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
@@ -320,8 +318,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* the backend using conditional GET. When no matching cache entry is found,
|
||||
* it triggers "miss" processing.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
@@ -366,9 +363,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* The original request is used as a template for a conditional
|
||||
* GET request with the backend.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param Response $entry A Response instance to validate
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -429,8 +424,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* Unconditionally fetches a fresh response from the backend and
|
||||
* stores it in the cache if is cacheable.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to process exceptions
|
||||
* @param bool $catch Whether to process exceptions
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -462,9 +456,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
* All backend requests (cache passes, fetches, cache validations)
|
||||
* run through this method.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param Response $entry A Response instance (the stale entry if present, null otherwise)
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param Response|null $entry A Response instance (the stale entry if present, null otherwise)
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*/
|
||||
@@ -642,10 +635,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Checks if the Request includes authorization or other sensitive information
|
||||
* that should cause the Response to be considered private by default.
|
||||
*
|
||||
* @return bool true if the Request is private, false otherwise
|
||||
*/
|
||||
private function isPrivateRequest(Request $request)
|
||||
private function isPrivateRequest(Request $request): bool
|
||||
{
|
||||
foreach ($this->options['private_headers'] as $key) {
|
||||
$key = strtolower(str_replace('HTTP_', '', $key));
|
||||
|
||||
@@ -130,7 +130,6 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
$response->headers->set('Cache-Control', implode(', ', array_keys($flags)));
|
||||
|
||||
$maxAge = null;
|
||||
$sMaxage = null;
|
||||
|
||||
if (is_numeric($this->ageDirectives['max-age'])) {
|
||||
$maxAge = $this->ageDirectives['max-age'] + $this->age;
|
||||
@@ -156,10 +155,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
* RFC2616, Section 13.4.
|
||||
*
|
||||
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function willMakeFinalResponseUncacheable(Response $response)
|
||||
private function willMakeFinalResponseUncacheable(Response $response): bool
|
||||
{
|
||||
// RFC2616: A response received with a status code of 200, 203, 300, 301 or 410
|
||||
// MAY be stored by a cache […] unless a cache-control directive prohibits caching.
|
||||
@@ -203,12 +200,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
*
|
||||
* If the value is lower than the currently stored value, we update the value, to keep a rolling
|
||||
* minimal value of each instruction. If the value is NULL, the directive will not be set on the final response.
|
||||
*
|
||||
* @param string $directive
|
||||
* @param int|null $value
|
||||
* @param int $age
|
||||
*/
|
||||
private function storeRelativeAgeDirective($directive, $value, $age)
|
||||
private function storeRelativeAgeDirective(string $directive, ?int $value, int $age)
|
||||
{
|
||||
if (null === $value) {
|
||||
$this->ageDirectives[$directive] = false;
|
||||
|
||||
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
2
vendor/symfony/http-kernel/HttpCache/Ssi.php
vendored
@@ -94,5 +94,7 @@ class Ssi extends AbstractSurrogate
|
||||
|
||||
// remove SSI/1.0 from the Surrogate-Control header
|
||||
$this->removeFromControl($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
63
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
63
vendor/symfony/http-kernel/HttpCache/Store.php
vendored
@@ -132,7 +132,7 @@ class Store implements StoreInterface
|
||||
$key = $this->getCacheKey($request);
|
||||
|
||||
if (!$entries = $this->getMetadata($key)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
// find a cached entry that matches the request.
|
||||
@@ -146,7 +146,7 @@ class Store implements StoreInterface
|
||||
}
|
||||
|
||||
if (null === $match) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$headers = $match[1];
|
||||
@@ -157,6 +157,7 @@ class Store implements StoreInterface
|
||||
// TODO the metaStore referenced an entity that doesn't exist in
|
||||
// the entityStore. We definitely want to return nil but we should
|
||||
// also purge the entry from the meta-store when this is detected.
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ class Store implements StoreInterface
|
||||
if (!$response->headers->has('X-Content-Digest')) {
|
||||
$digest = $this->generateContentDigest($response);
|
||||
|
||||
if (false === $this->save($digest, $response->getContent())) {
|
||||
if (!$this->save($digest, $response->getContent())) {
|
||||
throw new \RuntimeException('Unable to store the entity.');
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ class Store implements StoreInterface
|
||||
|
||||
array_unshift($entries, [$storedEnv, $headers]);
|
||||
|
||||
if (false === $this->save($key, serialize($entries))) {
|
||||
if (!$this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ class Store implements StoreInterface
|
||||
}
|
||||
}
|
||||
|
||||
if ($modified && false === $this->save($key, serialize($entries))) {
|
||||
if ($modified && !$this->save($key, serialize($entries))) {
|
||||
throw new \RuntimeException('Unable to store the metadata.');
|
||||
}
|
||||
}
|
||||
@@ -258,10 +259,8 @@ class Store implements StoreInterface
|
||||
* @param string $vary A Response vary header
|
||||
* @param array $env1 A Request HTTP header array
|
||||
* @param array $env2 A Request HTTP header array
|
||||
*
|
||||
* @return bool true if the two environments match, false otherwise
|
||||
*/
|
||||
private function requestsMatch($vary, $env1, $env2)
|
||||
private function requestsMatch(?string $vary, array $env1, array $env2): bool
|
||||
{
|
||||
if (empty($vary)) {
|
||||
return true;
|
||||
@@ -283,12 +282,8 @@ class Store implements StoreInterface
|
||||
* Gets all data associated with the given key.
|
||||
*
|
||||
* Use this method only if you know what you are doing.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return array An array of data associated with the key
|
||||
*/
|
||||
private function getMetadata($key)
|
||||
private function getMetadata(string $key): array
|
||||
{
|
||||
if (!$entries = $this->load($key)) {
|
||||
return [];
|
||||
@@ -319,12 +314,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Purges data for the given URL.
|
||||
*
|
||||
* @param string $url A URL
|
||||
*
|
||||
* @return bool true if the URL exists and has been purged, false otherwise
|
||||
*/
|
||||
private function doPurge($url)
|
||||
private function doPurge(string $url): bool
|
||||
{
|
||||
$key = $this->getCacheKey(Request::create($url));
|
||||
if (isset($this->locks[$key])) {
|
||||
@@ -344,27 +335,18 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Loads data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
*
|
||||
* @return string The data associated with the key
|
||||
*/
|
||||
private function load($key)
|
||||
private function load(string $key): ?string
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
return file_exists($path) ? file_get_contents($path) : false;
|
||||
return file_exists($path) && false !== ($contents = file_get_contents($path)) ? $contents : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data for the given key.
|
||||
*
|
||||
* @param string $key The store key
|
||||
* @param string $data The data to store
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function save($key, $data)
|
||||
private function save(string $key, string $data): bool
|
||||
{
|
||||
$path = $this->getPath($key);
|
||||
|
||||
@@ -406,6 +388,8 @@ class Store implements StoreInterface
|
||||
}
|
||||
|
||||
@chmod($path, 0666 & ~umask());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getPath($key)
|
||||
@@ -432,10 +416,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Returns a cache key for the given Request.
|
||||
*
|
||||
* @return string A key for the given Request
|
||||
*/
|
||||
private function getCacheKey(Request $request)
|
||||
private function getCacheKey(Request $request): string
|
||||
{
|
||||
if (isset($this->keyCache[$request])) {
|
||||
return $this->keyCache[$request];
|
||||
@@ -446,20 +428,16 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Persists the Request HTTP headers.
|
||||
*
|
||||
* @return array An array of HTTP headers
|
||||
*/
|
||||
private function persistRequest(Request $request)
|
||||
private function persistRequest(Request $request): array
|
||||
{
|
||||
return $request->headers->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the Response HTTP headers.
|
||||
*
|
||||
* @return array An array of HTTP headers
|
||||
*/
|
||||
private function persistResponse(Response $response)
|
||||
private function persistResponse(Response $response): array
|
||||
{
|
||||
$headers = $response->headers->all();
|
||||
$headers['X-Status'] = [$response->getStatusCode()];
|
||||
@@ -469,13 +447,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Restores a Response from the HTTP headers and body.
|
||||
*
|
||||
* @param array $headers An array of HTTP headers for the Response
|
||||
* @param string $body The Response body
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
private function restoreResponse($headers, $body = null)
|
||||
private function restoreResponse(array $headers, string $body = null): Response
|
||||
{
|
||||
$status = $headers['X-Status'][0];
|
||||
unset($headers['X-Status']);
|
||||
|
||||
@@ -78,10 +78,9 @@ interface SurrogateInterface
|
||||
/**
|
||||
* Handles a Surrogate from the cache.
|
||||
*
|
||||
* @param HttpCache $cache An HttpCache instance
|
||||
* @param string $uri The main URI
|
||||
* @param string $alt An alternative URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
* @param string $uri The main URI
|
||||
* @param string $alt An alternative URI
|
||||
* @param bool $ignoreErrors Whether to ignore errors or not
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
|
||||
@@ -39,7 +39,7 @@ final class HttpClientKernel implements HttpKernelInterface
|
||||
$this->client = $client ?? HttpClient::create();
|
||||
}
|
||||
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true): Response
|
||||
{
|
||||
$headers = $this->getHeaders($request);
|
||||
$body = '';
|
||||
@@ -56,7 +56,7 @@ final class HttpClientKernel implements HttpKernelInterface
|
||||
$response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch));
|
||||
|
||||
$response->headers = new class($response->headers->all()) extends ResponseHeaderBag {
|
||||
protected function computeCacheControlValue()
|
||||
protected function computeCacheControlValue(): string
|
||||
{
|
||||
return $this->getCacheControlHeader(); // preserve the original value
|
||||
}
|
||||
|
||||
33
vendor/symfony/http-kernel/HttpKernel.php
vendored
33
vendor/symfony/http-kernel/HttpKernel.php
vendored
@@ -62,7 +62,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
*/
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
$request->headers->set('X-Php-Ob-Level', ob_get_level());
|
||||
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
|
||||
|
||||
try {
|
||||
return $this->handleRaw($request, $type);
|
||||
@@ -76,7 +76,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $this->handleException($e, $request, $type);
|
||||
return $this->handleThrowable($e, $request, $type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,13 +91,13 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function terminateWithException(\Exception $exception, Request $request = null)
|
||||
public function terminateWithException(\Throwable $exception, Request $request = null)
|
||||
{
|
||||
if (!$request = $request ?: $this->requestStack->getMasterRequest()) {
|
||||
throw $exception;
|
||||
}
|
||||
|
||||
$response = $this->handleException($exception, $request, self::MASTER_REQUEST);
|
||||
$response = $this->handleThrowable($exception, $request, self::MASTER_REQUEST);
|
||||
|
||||
$response->sendHeaders();
|
||||
$response->sendContent();
|
||||
@@ -110,15 +110,10 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* Exceptions are not caught.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
* @throws \LogicException If one of the listener does not behave as expected
|
||||
* @throws NotFoundHttpException When controller cannot be found
|
||||
*/
|
||||
private function handleRaw(Request $request, int $type = self::MASTER_REQUEST)
|
||||
private function handleRaw(Request $request, int $type = self::MASTER_REQUEST): Response
|
||||
{
|
||||
$this->requestStack->push($request);
|
||||
|
||||
@@ -175,15 +170,9 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Filters a response object.
|
||||
*
|
||||
* @param Response $response A Response instance
|
||||
* @param Request $request An error message in case the response is not a Response object
|
||||
* @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
|
||||
*
|
||||
* @return Response The filtered Response instance
|
||||
*
|
||||
* @throws \RuntimeException if the passed object is not a Response instance
|
||||
*/
|
||||
private function filterResponse(Response $response, Request $request, int $type)
|
||||
private function filterResponse(Response $response, Request $request, int $type): Response
|
||||
{
|
||||
$event = new ResponseEvent($this, $request, $type, $response);
|
||||
|
||||
@@ -208,21 +197,17 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an exception by trying to convert it to a Response.
|
||||
*
|
||||
* @param \Exception $e An \Exception instance
|
||||
* @param Request $request A Request instance
|
||||
* @param int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
|
||||
* Handles a throwable by trying to convert it to a Response.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function handleException(\Exception $e, Request $request, int $type): Response
|
||||
private function handleThrowable(\Throwable $e, Request $request, int $type): Response
|
||||
{
|
||||
$event = new ExceptionEvent($this, $request, $type, $e);
|
||||
$this->dispatcher->dispatch($event, KernelEvents::EXCEPTION);
|
||||
|
||||
// a listener might have replaced the exception
|
||||
$e = $event->getException();
|
||||
$e = $event->getThrowable();
|
||||
|
||||
if (!$event->hasResponse()) {
|
||||
$this->finishRequest($request, $type);
|
||||
|
||||
@@ -30,10 +30,9 @@ interface HttpKernelInterface
|
||||
* When $catch is true, the implementation must catch all exceptions
|
||||
* and do its best to convert them to a Response instance.
|
||||
*
|
||||
* @param Request $request A Request instance
|
||||
* @param int $type The type of the request
|
||||
* (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param int $type The type of the request
|
||||
* (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
*
|
||||
* @return Response A Response instance
|
||||
*
|
||||
|
||||
170
vendor/symfony/http-kernel/Kernel.php
vendored
170
vendor/symfony/http-kernel/Kernel.php
vendored
@@ -16,7 +16,7 @@ use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
use Symfony\Component\Config\Loader\DelegatingLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Debug\DebugClassLoader;
|
||||
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@@ -29,6 +29,7 @@ use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -73,15 +74,17 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
private $requestStackSize = 0;
|
||||
private $resetServices = false;
|
||||
|
||||
const VERSION = '4.3.2';
|
||||
const VERSION_ID = 40302;
|
||||
private static $freshCache = [];
|
||||
|
||||
const VERSION = '4.4.0';
|
||||
const VERSION_ID = 40400;
|
||||
const MAJOR_VERSION = 4;
|
||||
const MINOR_VERSION = 3;
|
||||
const RELEASE_VERSION = 2;
|
||||
const MINOR_VERSION = 4;
|
||||
const RELEASE_VERSION = 0;
|
||||
const EXTRA_VERSION = '';
|
||||
|
||||
const END_OF_MAINTENANCE = '01/2020';
|
||||
const END_OF_LIFE = '07/2020';
|
||||
const END_OF_MAINTENANCE = '11/2022';
|
||||
const END_OF_LIFE = '11/2023';
|
||||
|
||||
public function __construct(string $environment, bool $debug)
|
||||
{
|
||||
@@ -204,7 +207,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
/**
|
||||
* Gets a HTTP kernel from the container.
|
||||
*
|
||||
* @return HttpKernel
|
||||
* @return HttpKernelInterface
|
||||
*/
|
||||
protected function getHttpKernel()
|
||||
{
|
||||
@@ -236,11 +239,21 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
|
||||
*/
|
||||
public function locateResource($name, $dir = null, $first = true)
|
||||
public function locateResource($name/*, $dir = null, $first = true, $triggerDeprecation = true*/)
|
||||
{
|
||||
if (2 <= \func_num_args()) {
|
||||
$dir = func_get_arg(1);
|
||||
$first = 3 <= \func_num_args() ? func_get_arg(2) : true;
|
||||
|
||||
if (4 !== \func_num_args() || func_get_arg(3)) {
|
||||
@trigger_error(sprintf('Passing more than one argument to %s is deprecated since Symfony 4.4 and will be removed in 5.0.', __METHOD__), E_USER_DEPRECATED);
|
||||
}
|
||||
} else {
|
||||
$dir = null;
|
||||
$first = true;
|
||||
}
|
||||
|
||||
if ('@' !== $name[0]) {
|
||||
throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
|
||||
}
|
||||
@@ -262,6 +275,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
|
||||
if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
|
||||
$files[] = $file;
|
||||
|
||||
// see https://symfony.com/doc/current/bundles/override.html on how to overwrite parts of a bundle
|
||||
@trigger_error(sprintf('Overwriting the resource "%s" with "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $name, $file), E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
if (file_exists($file = $bundle->getPath().'/'.$path)) {
|
||||
@@ -343,7 +359,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
{
|
||||
if (null === $this->projectDir) {
|
||||
$r = new \ReflectionObject($this);
|
||||
$dir = $rootDir = \dirname($r->getFileName());
|
||||
|
||||
if (!file_exists($dir = $r->getFileName())) {
|
||||
throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
|
||||
}
|
||||
|
||||
$dir = $rootDir = \dirname($dir);
|
||||
while (!file_exists($dir.'/composer.json')) {
|
||||
if ($dir === \dirname($dir)) {
|
||||
return $this->projectDir = $rootDir;
|
||||
@@ -361,6 +382,10 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*/
|
||||
public function getContainer()
|
||||
{
|
||||
if (!$this->container) {
|
||||
@trigger_error('Getting the container from a non-booted kernel is deprecated since Symfony 4.4.', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
@@ -377,7 +402,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*/
|
||||
public function getStartTime()
|
||||
{
|
||||
return $this->debug ? $this->startTime : -INF;
|
||||
return $this->debug && null !== $this->startTime ? $this->startTime : -INF;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -482,31 +507,79 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$class = $this->getContainerClass();
|
||||
$cacheDir = $this->warmupDir ?: $this->getCacheDir();
|
||||
$cache = new ConfigCache($cacheDir.'/'.$class.'.php', $this->debug);
|
||||
$oldContainer = null;
|
||||
if ($fresh = $cache->isFresh()) {
|
||||
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
|
||||
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
|
||||
$fresh = $oldContainer = false;
|
||||
try {
|
||||
if (file_exists($cache->getPath()) && \is_object($this->container = include $cache->getPath())) {
|
||||
$this->container->set('kernel', $this);
|
||||
$oldContainer = $this->container;
|
||||
$fresh = true;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} finally {
|
||||
$cachePath = $cache->getPath();
|
||||
|
||||
// Silence E_WARNING to ignore "include" failures - don't use "@" to prevent silencing fatal errors
|
||||
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
|
||||
|
||||
try {
|
||||
if (file_exists($cachePath) && \is_object($this->container = include $cachePath)
|
||||
&& (!$this->debug || (self::$freshCache[$k = $cachePath.'.'.$this->environment] ?? self::$freshCache[$k] = $cache->isFresh()))
|
||||
) {
|
||||
$this->container->set('kernel', $this);
|
||||
error_reporting($errorLevel);
|
||||
|
||||
return;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
}
|
||||
|
||||
if ($fresh) {
|
||||
return;
|
||||
$oldContainer = \is_object($this->container) ? new \ReflectionClass($this->container) : $this->container = null;
|
||||
|
||||
try {
|
||||
is_dir($cacheDir) ?: mkdir($cacheDir, 0777, true);
|
||||
|
||||
if ($lock = fopen($cachePath, 'w')) {
|
||||
chmod($cachePath, 0666 & ~umask());
|
||||
flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
|
||||
|
||||
if (!flock($lock, $wouldBlock ? LOCK_SH : LOCK_EX)) {
|
||||
fclose($lock);
|
||||
} else {
|
||||
$cache = new class($cachePath, $this->debug) extends ConfigCache {
|
||||
public $lock;
|
||||
|
||||
public function write($content, array $metadata = null)
|
||||
{
|
||||
rewind($this->lock);
|
||||
ftruncate($this->lock, 0);
|
||||
fwrite($this->lock, $content);
|
||||
|
||||
if (null !== $metadata) {
|
||||
file_put_contents($this->getPath().'.meta', serialize($metadata));
|
||||
@chmod($this->getPath().'.meta', 0666 & ~umask());
|
||||
}
|
||||
|
||||
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
|
||||
opcache_invalidate($this->getPath(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
flock($this->lock, LOCK_UN);
|
||||
fclose($this->lock);
|
||||
}
|
||||
};
|
||||
$cache->lock = $lock;
|
||||
|
||||
if (!\is_object($this->container = include $cachePath)) {
|
||||
$this->container = null;
|
||||
} elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) {
|
||||
$this->container->set('kernel', $this);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
} finally {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
|
||||
$collectedLogs = [];
|
||||
$previousHandler = \defined('PHPUNIT_COMPOSER_INSTALL');
|
||||
$previousHandler = $previousHandler ?: set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
|
||||
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
|
||||
return $previousHandler ? $previousHandler($type, $message, $file, $line) : false;
|
||||
}
|
||||
@@ -514,7 +587,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
if (isset($collectedLogs[$message])) {
|
||||
++$collectedLogs[$message]['count'];
|
||||
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
|
||||
@@ -527,7 +600,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
}
|
||||
// Remove frames added by DebugClassLoader.
|
||||
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
|
||||
if (DebugClassLoader::class === ($backtrace[$i]['class'] ?? null)) {
|
||||
if (\in_array($backtrace[$i]['class'] ?? null, [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
|
||||
$backtrace = [$backtrace[$i + 1]];
|
||||
break;
|
||||
}
|
||||
@@ -541,6 +614,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
'trace' => [$backtrace[0]],
|
||||
'count' => 1,
|
||||
];
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -549,7 +624,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$container = $this->buildContainer();
|
||||
$container->compile();
|
||||
} finally {
|
||||
if ($this->debug && true !== $previousHandler) {
|
||||
if ($collectDeprecations) {
|
||||
restore_error_handler();
|
||||
|
||||
file_put_contents($cacheDir.'/'.$class.'Deprecations.log', serialize(array_values($collectedLogs)));
|
||||
@@ -557,19 +632,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $oldContainer && file_exists($cache->getPath())) {
|
||||
$errorLevel = error_reporting(\E_ALL ^ \E_WARNING);
|
||||
try {
|
||||
$oldContainer = include $cache->getPath();
|
||||
} catch (\Throwable $e) {
|
||||
} finally {
|
||||
error_reporting($errorLevel);
|
||||
}
|
||||
}
|
||||
$oldContainer = \is_object($oldContainer) ? new \ReflectionClass($oldContainer) : false;
|
||||
|
||||
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
|
||||
$this->container = require $cache->getPath();
|
||||
unset($cache);
|
||||
$this->container = require $cachePath;
|
||||
$this->container->set('kernel', $this);
|
||||
|
||||
if ($oldContainer && \get_class($this->container) !== $oldContainer->name) {
|
||||
@@ -579,7 +644,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
static $legacyContainers = [];
|
||||
$oldContainerDir = \dirname($oldContainer->getFileName());
|
||||
$legacyContainers[$oldContainerDir.'.legacy'] = true;
|
||||
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy') as $legacyContainer) {
|
||||
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', GLOB_NOSORT) as $legacyContainer) {
|
||||
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
|
||||
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
|
||||
}
|
||||
@@ -717,10 +782,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
/**
|
||||
* Dumps the service container to PHP code in the cache.
|
||||
*
|
||||
* @param ConfigCache $cache The config cache
|
||||
* @param ContainerBuilder $container The service container
|
||||
* @param string $class The name of the class to generate
|
||||
* @param string $baseClass The name of the container's base class
|
||||
* @param string $class The name of the class to generate
|
||||
* @param string $baseClass The name of the container's base class
|
||||
*/
|
||||
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
|
||||
{
|
||||
@@ -748,7 +811,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$fs->dumpFile($dir.$file, $code);
|
||||
@chmod($dir.$file, 0666 & ~umask());
|
||||
}
|
||||
$legacyFile = \dirname($dir.$file).'.legacy';
|
||||
$legacyFile = \dirname($dir.key($content)).'.legacy';
|
||||
if (file_exists($legacyFile)) {
|
||||
@unlink($legacyFile);
|
||||
}
|
||||
@@ -858,6 +921,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$this->__construct($environment, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
|
||||
|
||||
19
vendor/symfony/http-kernel/KernelInterface.php
vendored
19
vendor/symfony/http-kernel/KernelInterface.php
vendored
@@ -80,23 +80,14 @@ interface KernelInterface extends HttpKernelInterface
|
||||
* where BundleName is the name of the bundle
|
||||
* and the remaining part is the relative path in the bundle.
|
||||
*
|
||||
* If $dir is passed, and the first segment of the path is "Resources",
|
||||
* this method will look for a file named:
|
||||
* @param string $name A resource name to locate
|
||||
*
|
||||
* $dir/<BundleName>/path/without/Resources
|
||||
*
|
||||
* before looking in the bundle resource folder.
|
||||
*
|
||||
* @param string $name A resource name to locate
|
||||
* @param string $dir A directory where to look for the resource first
|
||||
* @param bool $first Whether to return the first path or paths for all matching bundles
|
||||
*
|
||||
* @return string|array The absolute path of the resource or an array if $first is false
|
||||
* @return string|array The absolute path of the resource or an array if $first is false (array return value is deprecated)
|
||||
*
|
||||
* @throws \InvalidArgumentException if the file cannot be found or the name is not valid
|
||||
* @throws \RuntimeException if the name contains invalid/unsafe characters
|
||||
*/
|
||||
public function locateResource($name, $dir = null, $first = true);
|
||||
public function locateResource($name/*, $dir = null, $first = true*/);
|
||||
|
||||
/**
|
||||
* Gets the name of the kernel.
|
||||
@@ -133,14 +124,14 @@ interface KernelInterface extends HttpKernelInterface
|
||||
/**
|
||||
* Gets the current container.
|
||||
*
|
||||
* @return ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown
|
||||
* @return ContainerInterface
|
||||
*/
|
||||
public function getContainer();
|
||||
|
||||
/**
|
||||
* Gets the request start time (not available if debug is disabled).
|
||||
*
|
||||
* @return int The request start timestamp
|
||||
* @return float The request start timestamp
|
||||
*/
|
||||
public function getStartTime();
|
||||
|
||||
|
||||
2
vendor/symfony/http-kernel/Log/Logger.php
vendored
2
vendor/symfony/http-kernel/Log/Logger.php
vendored
@@ -65,6 +65,8 @@ class Logger extends AbstractLogger
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function log($level, $message, array $context = [])
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null): array
|
||||
{
|
||||
$file = $this->getIndexFilename();
|
||||
|
||||
@@ -113,10 +113,14 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token)
|
||||
public function read($token): ?Profile
|
||||
{
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
}
|
||||
|
||||
return $this->createProfileFromData($token, unserialize(file_get_contents($file)));
|
||||
@@ -127,7 +131,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function write(Profile $profile)
|
||||
public function write(Profile $profile): bool
|
||||
{
|
||||
$file = $this->getFilename($profile->getToken());
|
||||
|
||||
@@ -161,7 +165,14 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
'status_code' => $profile->getStatusCode(),
|
||||
];
|
||||
|
||||
if (false === file_put_contents($file, serialize($data))) {
|
||||
$context = stream_context_create();
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
stream_context_set_option($context, 'zlib', 'level', 3);
|
||||
}
|
||||
|
||||
if (false === file_put_contents($file, serialize($data), 0, $context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,7 +238,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
$position = ftell($file);
|
||||
|
||||
if (0 === $position) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@@ -282,6 +293,10 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\function_exists('gzcompress')) {
|
||||
$file = 'compress.zlib://'.$file;
|
||||
}
|
||||
|
||||
$profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile));
|
||||
}
|
||||
|
||||
|
||||
14
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
14
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
@@ -99,7 +99,7 @@ class Profile
|
||||
/**
|
||||
* Returns the IP.
|
||||
*
|
||||
* @return string The IP
|
||||
* @return string|null The IP
|
||||
*/
|
||||
public function getIp()
|
||||
{
|
||||
@@ -119,7 +119,7 @@ class Profile
|
||||
/**
|
||||
* Returns the request method.
|
||||
*
|
||||
* @return string The request method
|
||||
* @return string|null The request method
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
@@ -134,13 +134,16 @@ class Profile
|
||||
/**
|
||||
* Returns the URL.
|
||||
*
|
||||
* @return string The URL
|
||||
* @return string|null The URL
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
@@ -177,7 +180,7 @@ class Profile
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
@@ -288,6 +291,9 @@ class Profile
|
||||
return isset($this->collectors[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'];
|
||||
|
||||
32
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
32
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
@@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\HttpKernel\Profiler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -63,12 +64,12 @@ class Profiler implements ResetInterface
|
||||
/**
|
||||
* Loads the Profile for the given Response.
|
||||
*
|
||||
* @return Profile|false A Profile instance
|
||||
* @return Profile|null A Profile instance
|
||||
*/
|
||||
public function loadProfileFromResponse(Response $response)
|
||||
{
|
||||
if (!$token = $response->headers->get('X-Debug-Token')) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->loadProfile($token);
|
||||
@@ -79,7 +80,7 @@ class Profiler implements ResetInterface
|
||||
*
|
||||
* @param string $token A token
|
||||
*
|
||||
* @return Profile A Profile instance
|
||||
* @return Profile|null A Profile instance
|
||||
*/
|
||||
public function loadProfile($token)
|
||||
{
|
||||
@@ -128,7 +129,7 @@ class Profiler implements ResetInterface
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*
|
||||
* @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats
|
||||
* @see https://php.net/datetime.formats for the supported date/time formats
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null)
|
||||
{
|
||||
@@ -138,12 +139,16 @@ class Profiler implements ResetInterface
|
||||
/**
|
||||
* Collects data for the given Response.
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*
|
||||
* @return Profile|null A Profile instance or null if the profiler is disabled
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
{
|
||||
$exception = 2 < \func_num_args() ? func_get_arg(2) : null;
|
||||
|
||||
if (false === $this->enabled) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
|
||||
@@ -163,9 +168,14 @@ class Profiler implements ResetInterface
|
||||
|
||||
$response->headers->set('X-Debug-Token', $profile->getToken());
|
||||
|
||||
$wrappedException = null;
|
||||
foreach ($this->collectors as $collector) {
|
||||
$collector->collect($request, $response, $exception);
|
||||
if (($e = $exception) instanceof \Error) {
|
||||
$r = new \ReflectionMethod($collector, 'collect');
|
||||
$e = 2 >= $r->getNumberOfParameters() || !($p = $r->getParameters()[2])->hasType() || \Exception::class !== $p->getType()->getName() ? $e : ($wrappedException ?? $wrappedException = new FatalThrowableError($e));
|
||||
}
|
||||
|
||||
$collector->collect($request, $response, $e);
|
||||
// we need to clone for sub-requests
|
||||
$profile->addCollector(clone $collector);
|
||||
}
|
||||
@@ -242,16 +252,16 @@ class Profiler implements ResetInterface
|
||||
return $this->collectors[$name];
|
||||
}
|
||||
|
||||
private function getTimestamp($value)
|
||||
private function getTimestamp(?string $value): ?int
|
||||
{
|
||||
if (null === $value || '' == $value) {
|
||||
return;
|
||||
if (null === $value || '' === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$value = new \DateTime(is_numeric($value) ? '@'.$value : $value);
|
||||
} catch (\Exception $e) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value->getTimestamp();
|
||||
|
||||
@@ -38,7 +38,7 @@ interface ProfilerStorageInterface
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null);
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null): array;
|
||||
|
||||
/**
|
||||
* Reads data associated with the given token.
|
||||
@@ -47,16 +47,16 @@ interface ProfilerStorageInterface
|
||||
*
|
||||
* @param string $token A token
|
||||
*
|
||||
* @return Profile The profile associated with token
|
||||
* @return Profile|null The profile associated with token
|
||||
*/
|
||||
public function read($token);
|
||||
public function read($token): ?Profile;
|
||||
|
||||
/**
|
||||
* Saves a Profile.
|
||||
*
|
||||
* @return bool Write operation successful
|
||||
*/
|
||||
public function write(Profile $profile);
|
||||
public function write(Profile $profile): bool;
|
||||
|
||||
/**
|
||||
* Purges all data from the database.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user