package and depencies
This commit is contained in:
@@ -24,26 +24,24 @@ use Symfony\Component\VarDumper\Caster\ClassStub;
|
||||
*/
|
||||
class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
/**
|
||||
* @var KernelInterface
|
||||
*/
|
||||
private $kernel;
|
||||
private KernelInterface $kernel;
|
||||
|
||||
/**
|
||||
* Sets the Kernel associated with this Request.
|
||||
*/
|
||||
public function setKernel(KernelInterface $kernel = null)
|
||||
{
|
||||
if (1 > \func_num_args()) {
|
||||
trigger_deprecation('symfony/http-kernel', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
|
||||
}
|
||||
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
|
||||
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
|
||||
$eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
|
||||
$eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
|
||||
|
||||
$this->data = [
|
||||
'token' => $response->headers->get('X-Debug-Token'),
|
||||
@@ -60,15 +58,15 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
|
||||
'php_timezone' => date_default_timezone_get(),
|
||||
'xdebug_enabled' => \extension_loaded('xdebug'),
|
||||
'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN),
|
||||
'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN),
|
||||
'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL),
|
||||
'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL),
|
||||
'bundles' => [],
|
||||
'sapi_name' => \PHP_SAPI,
|
||||
];
|
||||
|
||||
if (isset($this->kernel)) {
|
||||
foreach ($this->kernel->getBundles() as $name => $bundle) {
|
||||
$this->data['bundles'][$name] = new ClassStub(\get_class($bundle));
|
||||
$this->data['bundles'][$name] = new ClassStub($bundle::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +76,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->data = [];
|
||||
@@ -108,9 +103,8 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of the current Symfony release.
|
||||
*
|
||||
* @return string One of: unknown, dev, stable, eom, eol
|
||||
* Returns the state of the current Symfony release
|
||||
* as one of: unknown, dev, stable, eom, eol.
|
||||
*/
|
||||
public function getSymfonyState(): string
|
||||
{
|
||||
@@ -126,9 +120,6 @@ 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'];
|
||||
@@ -168,9 +159,6 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $this->data['php_version_extra'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int The PHP architecture as number of bits (e.g. 32 or 64)
|
||||
*/
|
||||
public function getPhpArchitecture(): int
|
||||
{
|
||||
return $this->data['php_architecture'];
|
||||
@@ -199,19 +187,27 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
*
|
||||
* @return bool|string true if debug is enabled, false otherwise or a string if no kernel was set
|
||||
*/
|
||||
public function isDebug()
|
||||
public function isDebug(): bool|string
|
||||
{
|
||||
return $this->data['debug'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the XDebug is enabled.
|
||||
* Returns true if the Xdebug is enabled.
|
||||
*/
|
||||
public function hasXDebug(): bool
|
||||
public function hasXdebug(): bool
|
||||
{
|
||||
return $this->data['xdebug_enabled'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the function xdebug_info is available.
|
||||
*/
|
||||
public function hasXdebugInfo(): bool
|
||||
{
|
||||
return \function_exists('xdebug_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if APCu is enabled.
|
||||
*/
|
||||
@@ -241,24 +237,16 @@ class ConfigDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $this->data['sapi_name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'config';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to retrieve information about the current Symfony version.
|
||||
*
|
||||
* @return string One of: dev, stable, eom, eol
|
||||
*/
|
||||
private function determineSymfonyState(): string
|
||||
{
|
||||
$now = new \DateTime();
|
||||
$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');
|
||||
$now = new \DateTimeImmutable();
|
||||
$eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
|
||||
$eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->modify('last day of this month');
|
||||
|
||||
if ($now > $eol) {
|
||||
$versionState = 'eol';
|
||||
|
@@ -33,27 +33,20 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* @var ClonerInterface
|
||||
*/
|
||||
private $cloner;
|
||||
private ClonerInterface $cloner;
|
||||
|
||||
/**
|
||||
* Converts the variable into a serializable Data instance.
|
||||
*
|
||||
* This array can be displayed in the template using
|
||||
* the VarDumper component.
|
||||
*
|
||||
* @param mixed $var
|
||||
*
|
||||
* @return Data
|
||||
*/
|
||||
protected function cloneVar($var)
|
||||
protected function cloneVar(mixed $var): Data
|
||||
{
|
||||
if ($var instanceof Data) {
|
||||
return $var;
|
||||
}
|
||||
if (null === $this->cloner) {
|
||||
if (!isset($this->cloner)) {
|
||||
$this->cloner = new VarCloner();
|
||||
$this->cloner->setMaxItems(-1);
|
||||
$this->cloner->addCasters($this->getCasters());
|
||||
@@ -84,10 +77,7 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
return $casters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
return ['data'];
|
||||
}
|
||||
@@ -106,7 +96,7 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
/**
|
||||
* @internal to prevent implementing \Serializable
|
||||
*/
|
||||
final protected function unserialize($data)
|
||||
final protected function unserialize(string $data)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -31,23 +31,19 @@ use Symfony\Component\VarDumper\Server\Connection;
|
||||
*/
|
||||
class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
{
|
||||
private $stopwatch;
|
||||
private $fileLinkFormat;
|
||||
private $dataCount = 0;
|
||||
private $isCollected = true;
|
||||
private $clonesCount = 0;
|
||||
private $clonesIndex = 0;
|
||||
private $rootRefs;
|
||||
private $charset;
|
||||
private $requestStack;
|
||||
private $dumper;
|
||||
private $sourceContextProvider;
|
||||
private ?Stopwatch $stopwatch = null;
|
||||
private string|FileLinkFormatter|false $fileLinkFormat;
|
||||
private int $dataCount = 0;
|
||||
private bool $isCollected = true;
|
||||
private int $clonesCount = 0;
|
||||
private int $clonesIndex = 0;
|
||||
private array $rootRefs;
|
||||
private string $charset;
|
||||
private ?RequestStack $requestStack;
|
||||
private DataDumperInterface|Connection|null $dumper;
|
||||
private mixed $sourceContextProvider;
|
||||
|
||||
/**
|
||||
* @param string|FileLinkFormatter|null $fileLinkFormat
|
||||
* @param DataDumperInterface|Connection|null $dumper
|
||||
*/
|
||||
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null)
|
||||
public function __construct(Stopwatch $stopwatch = null, string|FileLinkFormatter $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, DataDumperInterface|Connection $dumper = null)
|
||||
{
|
||||
$fileLinkFormat = $fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
$this->stopwatch = $stopwatch;
|
||||
@@ -74,9 +70,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|
||||
public function dump(Data $data)
|
||||
{
|
||||
if ($this->stopwatch) {
|
||||
$this->stopwatch->start('dump');
|
||||
}
|
||||
$this->stopwatch?->start('dump');
|
||||
|
||||
['name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt] = $this->sourceContextProvider->getContext();
|
||||
|
||||
@@ -96,9 +90,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt');
|
||||
++$this->dataCount;
|
||||
|
||||
if ($this->stopwatch) {
|
||||
$this->stopwatch->stop('dump');
|
||||
}
|
||||
$this->stopwatch?->stop('dump');
|
||||
}
|
||||
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
@@ -138,9 +130,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|
||||
public function reset()
|
||||
{
|
||||
if ($this->stopwatch) {
|
||||
$this->stopwatch->reset();
|
||||
}
|
||||
$this->stopwatch?->reset();
|
||||
$this->data = [];
|
||||
$this->dataCount = 0;
|
||||
$this->isCollected = true;
|
||||
|
@@ -22,13 +22,15 @@ use Symfony\Contracts\Service\ResetInterface;
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @see TraceableEventDispatcher
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class EventDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
protected $dispatcher;
|
||||
private $requestStack;
|
||||
private $currentRequest;
|
||||
private ?EventDispatcherInterface $dispatcher;
|
||||
private ?RequestStack $requestStack;
|
||||
private ?Request $currentRequest = null;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher = null, RequestStack $requestStack = null)
|
||||
{
|
||||
@@ -36,9 +38,6 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
$this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null;
|
||||
@@ -70,8 +69,6 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $listeners An array of called listeners
|
||||
*
|
||||
* @see TraceableEventDispatcher
|
||||
*/
|
||||
public function setCalledListeners(array $listeners)
|
||||
@@ -81,10 +78,8 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
|
||||
/**
|
||||
* @see TraceableEventDispatcher
|
||||
*
|
||||
* @return array|Data
|
||||
*/
|
||||
public function getCalledListeners()
|
||||
public function getCalledListeners(): array|Data
|
||||
{
|
||||
return $this->data['called_listeners'];
|
||||
}
|
||||
@@ -99,10 +94,8 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
|
||||
/**
|
||||
* @see TraceableEventDispatcher
|
||||
*
|
||||
* @return array|Data
|
||||
*/
|
||||
public function getNotCalledListeners()
|
||||
public function getNotCalledListeners(): array|Data
|
||||
{
|
||||
return $this->data['not_called_listeners'];
|
||||
}
|
||||
@@ -119,17 +112,12 @@ class EventDataCollector extends DataCollector implements LateDataCollectorInter
|
||||
|
||||
/**
|
||||
* @see TraceableEventDispatcher
|
||||
*
|
||||
* @return array|Data
|
||||
*/
|
||||
public function getOrphanedEvents()
|
||||
public function getOrphanedEvents(): array|Data
|
||||
{
|
||||
return $this->data['orphaned_events'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'events';
|
||||
|
@@ -22,9 +22,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*/
|
||||
class ExceptionDataCollector extends DataCollector
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
if (null !== $exception) {
|
||||
@@ -34,9 +31,6 @@ class ExceptionDataCollector extends DataCollector
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->data = [];
|
||||
@@ -47,10 +41,7 @@ class ExceptionDataCollector extends DataCollector
|
||||
return isset($this->data['exception']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Exception|FlattenException
|
||||
*/
|
||||
public function getException()
|
||||
public function getException(): \Exception|FlattenException
|
||||
{
|
||||
return $this->data['exception'];
|
||||
}
|
||||
@@ -75,9 +66,6 @@ class ExceptionDataCollector extends DataCollector
|
||||
return $this->data['exception']->getTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'exception';
|
||||
|
@@ -24,15 +24,15 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
*/
|
||||
class LoggerDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
private $logger;
|
||||
private $containerPathPrefix;
|
||||
private $currentRequest;
|
||||
private $requestStack;
|
||||
private $processedLogs;
|
||||
private DebugLoggerInterface $logger;
|
||||
private ?string $containerPathPrefix;
|
||||
private ?Request $currentRequest = null;
|
||||
private ?RequestStack $requestStack;
|
||||
private ?array $processedLogs = null;
|
||||
|
||||
public function __construct(object $logger = null, string $containerPathPrefix = null, RequestStack $requestStack = null)
|
||||
{
|
||||
if (null !== $logger && $logger instanceof DebugLoggerInterface) {
|
||||
if ($logger instanceof DebugLoggerInterface) {
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
@@ -40,31 +40,22 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
$this->currentRequest = $this->requestStack && $this->requestStack->getMainRequest() !== $request ? $request : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
if ($this->logger instanceof DebugLoggerInterface) {
|
||||
if (isset($this->logger)) {
|
||||
$this->logger->clear();
|
||||
}
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lateCollect()
|
||||
{
|
||||
if (null !== $this->logger) {
|
||||
if (isset($this->logger)) {
|
||||
$containerDeprecationLogs = $this->getContainerDeprecationLogs();
|
||||
$this->data = $this->computeErrorsCount($containerDeprecationLogs);
|
||||
// get compiler logs later (only when they are needed) to improve performance
|
||||
@@ -187,9 +178,6 @@ class LoggerDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $this->cloneVar($this->getContainerCompilerLogs($this->data['compiler_logs_filepath'] ?? null));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'logger';
|
||||
|
@@ -26,17 +26,11 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
$this->updateMemoryUsage();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->data = [
|
||||
@@ -45,9 +39,6 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lateCollect()
|
||||
{
|
||||
$this->updateMemoryUsage();
|
||||
@@ -58,10 +49,7 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
return $this->data['memory'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|float
|
||||
*/
|
||||
public function getMemoryLimit()
|
||||
public function getMemoryLimit(): int|float
|
||||
{
|
||||
return $this->data['memory_limit'];
|
||||
}
|
||||
@@ -71,18 +59,12 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
$this->data['memory'] = memory_get_peak_usage(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'memory';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|float
|
||||
*/
|
||||
private function convertToBytes(string $memoryLimit)
|
||||
private function convertToBytes(string $memoryLimit): int|float
|
||||
{
|
||||
if ('-1' === $memoryLimit) {
|
||||
return -1;
|
||||
@@ -100,11 +82,11 @@ class MemoryDataCollector extends DataCollector implements LateDataCollectorInte
|
||||
|
||||
switch (substr($memoryLimit, -1)) {
|
||||
case 't': $max *= 1024;
|
||||
// no break
|
||||
// no break
|
||||
case 'g': $max *= 1024;
|
||||
// no break
|
||||
// no break
|
||||
case 'm': $max *= 1024;
|
||||
// no break
|
||||
// no break
|
||||
case 'k': $max *= 1024;
|
||||
}
|
||||
|
||||
|
@@ -34,9 +34,9 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
/**
|
||||
* @var \SplObjectStorage<Request, callable>
|
||||
*/
|
||||
private $controllers;
|
||||
private $sessionUsages = [];
|
||||
private $requestStack;
|
||||
private \SplObjectStorage $controllers;
|
||||
private array $sessionUsages = [];
|
||||
private ?RequestStack $requestStack;
|
||||
|
||||
public function __construct(RequestStack $requestStack = null)
|
||||
{
|
||||
@@ -44,9 +44,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
$this->requestStack = $requestStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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.
|
||||
@@ -110,7 +107,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
'session_metadata' => $sessionMetadata,
|
||||
'session_attributes' => $sessionAttributes,
|
||||
'session_usages' => array_values($this->sessionUsages),
|
||||
'stateless_check' => $this->requestStack && ($mainRequest = $this->requestStack->getMainRequest()) && $mainRequest->attributes->get('_stateless', false),
|
||||
'stateless_check' => $this->requestStack?->getMainRequest()?->attributes->get('_stateless') ?? false,
|
||||
'flashes' => $flashes,
|
||||
'path_info' => $request->getPathInfo(),
|
||||
'controller' => 'n/a',
|
||||
@@ -346,7 +343,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
* @return array|string|Data The controller as a string or array of data
|
||||
* with keys 'class', 'method', 'file' and 'line'
|
||||
*/
|
||||
public function getController()
|
||||
public function getController(): array|string|Data
|
||||
{
|
||||
return $this->data['controller'];
|
||||
}
|
||||
@@ -357,7 +354,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
* @return array|Data|false A legacy array of data from the previous redirection response
|
||||
* or false otherwise
|
||||
*/
|
||||
public function getRedirect()
|
||||
public function getRedirect(): array|Data|false
|
||||
{
|
||||
return $this->data['redirect'] ?? false;
|
||||
}
|
||||
@@ -391,9 +388,6 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'request';
|
||||
@@ -431,11 +425,9 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|object|array|null $controller The controller to parse
|
||||
*
|
||||
* @return array|string An array of controller data or a simple string
|
||||
*/
|
||||
private function parseController($controller)
|
||||
private function parseController(array|object|string|null $controller): array|string
|
||||
{
|
||||
if (\is_string($controller) && str_contains($controller, '::')) {
|
||||
$controller = explode('::', $controller);
|
||||
@@ -451,7 +443,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
'file' => $r->getFileName(),
|
||||
'line' => $r->getStartLine(),
|
||||
];
|
||||
} catch (\ReflectionException $e) {
|
||||
} catch (\ReflectionException) {
|
||||
if (\is_callable($controller)) {
|
||||
// using __call or __callStatic
|
||||
return [
|
||||
|
@@ -32,8 +32,6 @@ class RouterDataCollector extends DataCollector
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
@@ -61,7 +59,7 @@ class RouterDataCollector extends DataCollector
|
||||
];
|
||||
}
|
||||
|
||||
protected function guessRoute(Request $request, $controller)
|
||||
protected function guessRoute(Request $request, string|object|array $controller)
|
||||
{
|
||||
return 'n/a';
|
||||
}
|
||||
@@ -77,31 +75,22 @@ class RouterDataCollector extends DataCollector
|
||||
/**
|
||||
* @return bool Whether this request will result in a redirect
|
||||
*/
|
||||
public function getRedirect()
|
||||
public function getRedirect(): bool
|
||||
{
|
||||
return $this->data['redirect'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTargetUrl()
|
||||
public function getTargetUrl(): ?string
|
||||
{
|
||||
return $this->data['url'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTargetRoute()
|
||||
public function getTargetRoute(): ?string
|
||||
{
|
||||
return $this->data['route'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'router';
|
||||
}
|
||||
|
@@ -24,8 +24,8 @@ use Symfony\Component\Stopwatch\StopwatchEvent;
|
||||
*/
|
||||
class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
|
||||
{
|
||||
private $kernel;
|
||||
private $stopwatch;
|
||||
private ?KernelInterface $kernel;
|
||||
private ?Stopwatch $stopwatch;
|
||||
|
||||
public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch = null)
|
||||
{
|
||||
@@ -33,9 +33,6 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
$this->stopwatch = $stopwatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
if (null !== $this->kernel) {
|
||||
@@ -52,21 +49,13 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->data = [];
|
||||
|
||||
if (null !== $this->stopwatch) {
|
||||
$this->stopwatch->reset();
|
||||
}
|
||||
$this->stopwatch?->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function lateCollect()
|
||||
{
|
||||
if (null !== $this->stopwatch && isset($this->data['token'])) {
|
||||
@@ -133,9 +122,6 @@ class TimeDataCollector extends DataCollector implements LateDataCollectorInterf
|
||||
return $this->data['stopwatch_installed'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'time';
|
||||
|
Reference in New Issue
Block a user