upgrade to laravel 7 and set branch to v2

This commit is contained in:
2020-12-25 11:22:15 +00:00
parent 516105c492
commit 0ddd298350
4638 changed files with 132501 additions and 190226 deletions

View File

@@ -19,16 +19,11 @@ use Symfony\Component\HttpFoundation\Response;
*
* @author Bart van den Burg <bart@burgov.nl>
*
* @final since Symfony 4.4
* @final
*/
class AjaxDataCollector extends DataCollector
{
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
// all collecting is done client side
}

View File

@@ -20,7 +20,7 @@ use Symfony\Component\VarDumper\Caster\ClassStub;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
{
@@ -28,21 +28,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
* @var KernelInterface
*/
private $kernel;
private $name;
private $version;
public function __construct(string $name = null, string $version = null)
{
if (1 <= \func_num_args()) {
@trigger_error(sprintf('The "$name" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
}
if (2 <= \func_num_args()) {
@trigger_error(sprintf('The "$version" argument in method "%s()" is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
}
$this->name = $name;
$this->version = $version;
}
/**
* Sets the Kernel associated with this Request.
@@ -54,14 +39,10 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->data = [
'app_name' => $this->name,
'app_version' => $this->version,
'token' => $response->headers->get('X-Debug-Token'),
'symfony_version' => Kernel::VERSION,
'symfony_state' => 'unknown',
@@ -111,26 +92,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
$this->data = $this->cloneVar($this->data);
}
/**
* @deprecated since Symfony 4.2
*/
public function getApplicationName()
{
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
return $this->data['app_name'];
}
/**
* @deprecated since Symfony 4.2
*/
public function getApplicationVersion()
{
@trigger_error(sprintf('The method "%s()" is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
return $this->data['app_version'];
}
/**
* Gets the token.
*
@@ -246,20 +207,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
return $this->data['php_timezone'];
}
/**
* Gets the application name.
*
* @return string The application name
*
* @deprecated since Symfony 4.2
*/
public function getAppName()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
return 'n/a';
}
/**
* Gets the environment.
*

View File

@@ -38,29 +38,6 @@ abstract class DataCollector implements DataCollectorInterface
*/
private $cloner;
/**
* @deprecated since Symfony 4.3, store all the serialized state in the data property instead
*/
public function serialize()
{
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3, store all the serialized state in the data property instead.', __METHOD__), \E_USER_DEPRECATED);
$trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
$isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
}
/**
* @deprecated since Symfony 4.3, store all the serialized state in the data property instead
*/
public function unserialize($data)
{
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.3, store all the serialized state in the data property instead.', __METHOD__), \E_USER_DEPRECATED);
$this->data = \is_array($data) ? $data : unserialize($data);
}
/**
* Converts the variable into a serializable Data instance.
*
@@ -112,19 +89,24 @@ abstract class DataCollector implements DataCollectorInterface
*/
public function __sleep()
{
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
@trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3, store all the serialized state in the "data" property instead.', $c), \E_USER_DEPRECATED);
$this->data = $this->serialize();
}
return ['data'];
}
public function __wakeup()
{
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'unserialize'))->getDeclaringClass()->name) {
@trigger_error(sprintf('Implementing the "%s::unserialize()" method is deprecated since Symfony 4.3, store all the serialized state in the "data" property instead.', $c), \E_USER_DEPRECATED);
$this->unserialize($this->data);
}
}
/**
* @internal to prevent implementing \Serializable
*/
final protected function serialize()
{
}
/**
* @internal to prevent implementing \Serializable
*/
final protected function unserialize($data)
{
}
}

View File

@@ -24,10 +24,8 @@ interface DataCollectorInterface extends ResetInterface
{
/**
* Collects data for the given Request and Response.
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/);
public function collect(Request $request, Response $response, \Throwable $exception = null);
/**
* Returns the name of the collector.

View File

@@ -27,7 +27,7 @@ use Symfony\Component\VarDumper\Server\Connection;
/**
* @author Nicolas Grekas <p@tchwork.com>
*
* @final since Symfony 4.3
* @final
*/
class DumpDataCollector extends DataCollector implements DataDumperInterface
{
@@ -100,12 +100,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
}
}
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if (!$this->dataCount) {
$this->data = [];
@@ -187,12 +182,12 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
self::__construct($this->stopwatch, $fileLinkFormat, $charset);
}
public function getDumpsCount()
public function getDumpsCount(): int
{
return $this->dataCount;
}
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1): array
{
$data = fopen('php://memory', 'r+b');
@@ -219,7 +214,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
return $dumps;
}
public function getName()
public function getName(): string
{
return 'dump';
}

View File

@@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
@@ -24,7 +23,7 @@ use Symfony\Contracts\Service\ResetInterface;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class EventDataCollector extends DataCollector implements LateDataCollectorInterface
{
@@ -40,10 +39,8 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
$this->data = [
@@ -64,12 +61,9 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
public function lateCollect()
{
if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
if ($this->dispatcher instanceof TraceableEventDispatcher) {
$this->setCalledListeners($this->dispatcher->getCalledListeners($this->currentRequest));
$this->setNotCalledListeners($this->dispatcher->getNotCalledListeners($this->currentRequest));
}
if ($this->dispatcher instanceof TraceableEventDispatcher) {
$this->setOrphanedEvents($this->dispatcher->getOrphanedEvents($this->currentRequest));
}

View File

@@ -20,19 +20,15 @@ use Symfony\Component\HttpFoundation\Response;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class ExceptionDataCollector extends DataCollector
{
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $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::createFromThrowable($exception),

View File

@@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
{
@@ -43,10 +43,8 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->currentRequest = $this->requestStack && $this->requestStack->getMasterRequest() !== $request ? $request : null;
}
@@ -124,7 +122,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
private function getContainerDeprecationLogs(): array
{
if (null === $this->containerPathPrefix || !file_exists($file = $this->containerPathPrefix.'Deprecations.log')) {
if (null === $this->containerPathPrefix || !is_file($file = $this->containerPathPrefix.'Deprecations.log')) {
return [];
}
@@ -150,7 +148,7 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
private function getContainerCompilerLogs(string $compilerLogsFilepath = null): array
{
if (!file_exists($compilerLogsFilepath)) {
if (!is_file($compilerLogsFilepath)) {
return [];
}

View File

@@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Response;
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class MemoryDataCollector extends DataCollector implements LateDataCollectorInterface
{
@@ -30,10 +30,8 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
$this->updateMemoryUsage();
}

View File

@@ -15,31 +15,35 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class RequestDataCollector extends DataCollector implements EventSubscriberInterface, LateDataCollectorInterface
{
protected $controllers;
private $sessionUsages = [];
private $requestStack;
public function __construct()
public function __construct(?RequestStack $requestStack = null)
{
$this->controllers = new \SplObjectStorage();
$this->requestStack = $requestStack;
}
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $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 = [];
@@ -86,7 +90,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$this->data = [
'method' => $request->getMethod(),
'format' => $request->getRequestFormat(),
'content' => $content,
'content_type' => $response->headers->get('Content-Type', 'text/html'),
'status_text' => isset(Response::$statusTexts[$statusCode]) ? Response::$statusTexts[$statusCode] : '',
'status_code' => $statusCode,
@@ -102,6 +105,8 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
'response_cookies' => $responseCookies,
'session_metadata' => $sessionMetadata,
'session_attributes' => $sessionAttributes,
'session_usages' => array_values($this->sessionUsages),
'stateless_check' => $this->requestStack && $this->requestStack->getMasterRequest()->attributes->get('_stateless', false),
'flashes' => $flashes,
'path_info' => $request->getPathInfo(),
'controller' => 'n/a',
@@ -118,9 +123,13 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
}
if (isset($this->data['request_request']['_password'])) {
$encodedPassword = rawurlencode($this->data['request_request']['_password']);
$content = str_replace('_password='.$encodedPassword, '_password=******', $content);
$this->data['request_request']['_password'] = '******';
}
$this->data['content'] = $content;
foreach ($this->data as $key => $value) {
if (!\is_array($value)) {
continue;
@@ -172,6 +181,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
{
$this->data = [];
$this->controllers = new \SplObjectStorage();
$this->sessionUsages = [];
}
public function getMethod()
@@ -239,6 +249,16 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
return $this->data['session_attributes']->getValue();
}
public function getStatelessCheck()
{
return $this->data['stateless_check'];
}
public function getSessionUsages()
{
return $this->data['session_usages'];
}
public function getFlashes()
{
return $this->data['flashes']->getValue();
@@ -347,18 +367,12 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
return isset($this->data['forward_token']) ? $this->data['forward_token'] : null;
}
/**
* @final since Symfony 4.3
*/
public function onKernelController(FilterControllerEvent $event)
public function onKernelController(ControllerEvent $event)
{
$this->controllers[$event->getRequest()] = $event->getController();
}
/**
* @final since Symfony 4.3
*/
public function onKernelResponse(FilterResponseEvent $event)
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
@@ -385,6 +399,37 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
return 'request';
}
public function collectSessionUsage(): void
{
$trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
$traceEndIndex = \count($trace) - 1;
for ($i = $traceEndIndex; $i > 0; --$i) {
if (null !== ($class = $trace[$i]['class'] ?? null) && (is_subclass_of($class, SessionInterface::class) || is_subclass_of($class, SessionBagInterface::class))) {
$traceEndIndex = $i;
break;
}
}
if ((\count($trace) - 1) === $traceEndIndex) {
return;
}
// Remove part of the backtrace that belongs to session only
array_splice($trace, 0, $traceEndIndex);
// Merge identical backtraces generated by internal call reports
$name = sprintf('%s:%s', $trace[1]['class'] ?? $trace[0]['file'], $trace[0]['line']);
if (!\array_key_exists($name, $this->sessionUsages)) {
$this->sessionUsages[$name] = [
'name' => $name,
'file' => $trace[0]['file'],
'line' => $trace[0]['line'],
'trace' => $trace,
];
}
}
/**
* Parse a controller.
*
@@ -403,7 +448,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
$r = new \ReflectionMethod($controller[0], $controller[1]);
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => $r->getFileName(),
'line' => $r->getStartLine(),
@@ -412,7 +457,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
if (\is_callable($controller)) {
// using __call or __callStatic
return [
'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
'class' => \is_object($controller[0]) ? get_debug_type($controller[0]) : $controller[0],
'method' => $controller[1],
'file' => 'n/a',
'line' => 'n/a',

View File

@@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
/**
* @author Fabien Potencier <fabien@symfony.com>
@@ -34,11 +34,9 @@ class RouterDataCollector extends DataCollector
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*
* @final since Symfony 4.4
* @final
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if ($response instanceof RedirectResponse) {
$this->data['redirect'] = true;
@@ -70,10 +68,8 @@ class RouterDataCollector extends DataCollector
/**
* Remembers the controller associated to each request.
*
* @final since Symfony 4.3
*/
public function onKernelController(FilterControllerEvent $event)
public function onKernelController(ControllerEvent $event)
{
$this->controllers[$event->getRequest()] = $event->getController();
}

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Stopwatch\StopwatchEvent;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
* @final
*/
class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
{
@@ -35,10 +35,8 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
/**
* {@inheritdoc}
*
* @param \Throwable|null $exception
*/
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
public function collect(Request $request, Response $response, \Throwable $exception = null)
{
if (null !== $this->kernel) {
$startTime = $this->kernel->getStartTime();