First Commit
No files matched your search
@@ -0,0 +1,68 @@
|
||||
<?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\ErrorHandler;
|
||||
|
||||
use Psr\Log\AbstractLogger;
|
||||
|
||||
/**
|
||||
* A buffering logger that stacks logs for later.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class BufferingLogger extends AbstractLogger
|
||||
{
|
||||
private array $logs = [];
|
||||
|
||||
public function log($level, $message, array $context = []): void
|
||||
{
|
||||
$this->logs[] = [$level, $message, $context];
|
||||
}
|
||||
|
||||
public function cleanLogs(): array
|
||||
{
|
||||
$logs = $this->logs;
|
||||
$this->logs = [];
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->logs as [$level, $message, $context]) {
|
||||
if (str_contains($message, '{')) {
|
||||
foreach ($context as $key => $val) {
|
||||
if (null === $val || \is_scalar($val) || $val instanceof \Stringable) {
|
||||
$message = str_replace("{{$key}}", $val, $message);
|
||||
} elseif ($val instanceof \DateTimeInterface) {
|
||||
$message = str_replace("{{$key}}", $val->format(\DateTimeInterface::RFC3339), $message);
|
||||
} elseif (\is_object($val)) {
|
||||
$message = str_replace("{{$key}}", '[object '.get_debug_type($val).']', $message);
|
||||
} else {
|
||||
$message = str_replace("{{$key}}", '['.\gettype($val).']', $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
error_log(\sprintf('%s [%s] %s', date(\DateTimeInterface::RFC3339), $level, $message));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
8.1
|
||||
---
|
||||
|
||||
* Add argument `$deprecationsNamespacesMapping` to `DebugClassLoader::enable()` to configure namespace-to-vendor remapping for deprecation checks
|
||||
* Trigger `@method` deprecation notices on abstract classes
|
||||
* Add `MaxExecutionTimeError` and skip `http_response_code()` / `header()` calls in the default exception renderer for `OutOfMemoryError` and `MaxExecutionTimeError` to avoid PHP 8.5+ warnings
|
||||
|
||||
7.3
|
||||
---
|
||||
|
||||
* Add `error:dump` command
|
||||
|
||||
7.1
|
||||
---
|
||||
|
||||
* Increase log level to "error" at least for all PHP errors
|
||||
|
||||
6.4
|
||||
---
|
||||
|
||||
* `FlattenExceptionNormalizer` no longer implements `ContextAwareNormalizerInterface`
|
||||
|
||||
6.3
|
||||
---
|
||||
|
||||
* Display exception properties in the HTML error page
|
||||
|
||||
6.1
|
||||
---
|
||||
|
||||
* Report overridden `@final` constants and properties
|
||||
* Read environment variable `SYMFONY_IDE` to configure file link format
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
* Make `DebugClassLoader` trigger deprecation notices on missing return types
|
||||
* Add `SYMFONY_PATCH_TYPE_DECLARATIONS='force=2'` mode to `DebugClassLoader` to turn annotations into native return types
|
||||
|
||||
5.2.0
|
||||
-----
|
||||
|
||||
* added the ability to set `HtmlErrorRenderer::$template` to a custom template to render when not in debug mode.
|
||||
|
||||
5.1.0
|
||||
-----
|
||||
|
||||
* The `HtmlErrorRenderer` and `SerializerErrorRenderer` add `X-Debug-Exception` and `X-Debug-Exception-File` headers in debug mode.
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* added the component
|
||||
* added `ErrorHandler::call()` method utility to turn any PHP error into `\ErrorException`
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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\ErrorHandler\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\ErrorHandler\ErrorRenderer\ErrorRendererInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
|
||||
|
||||
/**
|
||||
* Dump error pages to plain HTML files that can be directly served by a web server.
|
||||
*
|
||||
* @author Loïck Piera <pyrech@gmail.com>
|
||||
*/
|
||||
#[AsCommand(
|
||||
name: 'error:dump',
|
||||
description: 'Dump error pages to plain HTML files that can be directly served by a web server',
|
||||
)]
|
||||
final class ErrorDumpCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Filesystem $filesystem,
|
||||
private readonly ErrorRendererInterface $errorRenderer,
|
||||
private readonly ?EntrypointLookupInterface $entrypointLookup = null,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->addArgument('path', InputArgument::REQUIRED, 'Path where to dump the error pages in')
|
||||
->addArgument('status-codes', InputArgument::IS_ARRAY, 'Status codes to dump error pages for, all of them by default')
|
||||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force directory removal before dumping new error pages')
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$path = $input->getArgument('path');
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->title('Dumping error pages');
|
||||
|
||||
$this->dump($io, $path, $input->getArgument('status-codes'), (bool) $input->getOption('force'));
|
||||
$io->success(\sprintf('Error pages have been dumped in "%s".', $path));
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function dump(SymfonyStyle $io, string $path, array $statusCodes, bool $force = false): void
|
||||
{
|
||||
if (!$statusCodes) {
|
||||
$statusCodes = array_filter(array_keys(Response::$statusTexts), static fn ($statusCode) => $statusCode >= 400);
|
||||
}
|
||||
|
||||
if ($force || ($this->filesystem->exists($path) && $io->confirm(\sprintf('The "%s" directory already exists. Do you want to remove it before dumping the error pages?', $path), false))) {
|
||||
$this->filesystem->remove($path);
|
||||
}
|
||||
|
||||
foreach ($statusCodes as $statusCode) {
|
||||
// Avoid assets to be included only on the first dumped page
|
||||
$this->entrypointLookup?->reset();
|
||||
|
||||
$this->filesystem->dumpFile($path.\DIRECTORY_SEPARATOR.$statusCode.'.html', $this->errorRenderer->render(new HttpException((int) $statusCode))->getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?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\ErrorHandler;
|
||||
|
||||
/**
|
||||
* Registers all the debug tools.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Debug
|
||||
{
|
||||
public static function enable(): ErrorHandler
|
||||
{
|
||||
error_reporting(\E_ALL & ~\E_DEPRECATED & ~\E_USER_DEPRECATED);
|
||||
|
||||
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
|
||||
ini_set('display_errors', 0);
|
||||
} elseif (!filter_var(\ini_get('log_errors'), \FILTER_VALIDATE_BOOL) || \ini_get('error_log')) {
|
||||
// CLI - display errors only if they're not already logged to STDERR
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
@ini_set('zend.assertions', 1);
|
||||
ini_set('assert.active', 1);
|
||||
ini_set('assert.exception', 1);
|
||||
|
||||
DebugClassLoader::enable();
|
||||
|
||||
return ErrorHandler::register(new ErrorHandler(new BufferingLogger(), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
class ClassNotFoundError extends \Error
|
||||
{
|
||||
public function __construct(string $message, \Throwable $previous)
|
||||
{
|
||||
parent::__construct($message, $previous->getCode(), $previous->getPrevious());
|
||||
|
||||
foreach ([
|
||||
'file' => $previous->getFile(),
|
||||
'line' => $previous->getLine(),
|
||||
'trace' => $previous->getTrace(),
|
||||
] as $property => $value) {
|
||||
$refl = new \ReflectionProperty(\Error::class, $property);
|
||||
$refl->setValue($this, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
class FatalError extends \Error
|
||||
{
|
||||
/**
|
||||
* @param array $error An array as returned by error_get_last()
|
||||
*/
|
||||
public function __construct(
|
||||
string $message,
|
||||
int $code,
|
||||
private array $error,
|
||||
?int $traceOffset = null,
|
||||
bool $traceArgs = true,
|
||||
?array $trace = null,
|
||||
) {
|
||||
parent::__construct($message, $code);
|
||||
|
||||
if (null !== $trace) {
|
||||
if (!$traceArgs) {
|
||||
foreach ($trace as &$frame) {
|
||||
unset($frame['args'], $frame['this'], $frame);
|
||||
}
|
||||
}
|
||||
} elseif (null !== $traceOffset) {
|
||||
if (\function_exists('xdebug_get_function_stack') && \in_array(\ini_get('xdebug.mode'), ['develop', false], true) && $trace = @xdebug_get_function_stack()) {
|
||||
if (0 < $traceOffset) {
|
||||
array_splice($trace, -$traceOffset);
|
||||
}
|
||||
|
||||
foreach ($trace as &$frame) {
|
||||
if (!isset($frame['type'])) {
|
||||
// XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695
|
||||
if (isset($frame['class'])) {
|
||||
$frame['type'] = '::';
|
||||
}
|
||||
} elseif ('dynamic' === $frame['type']) {
|
||||
$frame['type'] = '->';
|
||||
} elseif ('static' === $frame['type']) {
|
||||
$frame['type'] = '::';
|
||||
}
|
||||
|
||||
// XDebug also has a different name for the parameters array
|
||||
if (!$traceArgs) {
|
||||
unset($frame['params'], $frame['args']);
|
||||
} elseif (isset($frame['params']) && !isset($frame['args'])) {
|
||||
$frame['args'] = $frame['params'];
|
||||
unset($frame['params']);
|
||||
}
|
||||
}
|
||||
|
||||
unset($frame);
|
||||
$trace = array_reverse($trace);
|
||||
} else {
|
||||
$trace = [];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'file' => $error['file'],
|
||||
'line' => $error['line'],
|
||||
'trace' => $trace,
|
||||
] as $property => $value) {
|
||||
if (null !== $value) {
|
||||
$refl = new \ReflectionProperty(\Error::class, $property);
|
||||
$refl->setValue($this, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getError(): array
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
/**
|
||||
* Raised on shutdown when PHP's max_execution_time is exceeded.
|
||||
*
|
||||
* Instances bypass http_response_code() and header() calls in the default
|
||||
* renderer to avoid PHP 8.5+ warnings when adjusting response state after
|
||||
* the timeout has fired.
|
||||
*/
|
||||
class MaxExecutionTimeError extends FatalError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
/**
|
||||
* Raised on shutdown when PHP exhausts its memory_limit.
|
||||
*
|
||||
* Instances bypass http_response_code() and header() calls in the default
|
||||
* renderer to avoid PHP 8.5+ warnings when adjusting response state after
|
||||
* the fatal error has fired.
|
||||
*/
|
||||
class OutOfMemoryError extends FatalError
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
class UndefinedFunctionError extends \Error
|
||||
{
|
||||
public function __construct(string $message, \Throwable $previous)
|
||||
{
|
||||
parent::__construct($message, $previous->getCode(), $previous->getPrevious());
|
||||
|
||||
foreach ([
|
||||
'file' => $previous->getFile(),
|
||||
'line' => $previous->getLine(),
|
||||
'trace' => $previous->getTrace(),
|
||||
] as $property => $value) {
|
||||
$refl = new \ReflectionProperty(\Error::class, $property);
|
||||
$refl->setValue($this, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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\ErrorHandler\Error;
|
||||
|
||||
class UndefinedMethodError extends \Error
|
||||
{
|
||||
public function __construct(string $message, \Throwable $previous)
|
||||
{
|
||||
parent::__construct($message, $previous->getCode(), $previous->getPrevious());
|
||||
|
||||
foreach ([
|
||||
'file' => $previous->getFile(),
|
||||
'line' => $previous->getLine(),
|
||||
'trace' => $previous->getTrace(),
|
||||
] as $property => $value) {
|
||||
$refl = new \ReflectionProperty(\Error::class, $property);
|
||||
$refl->setValue($this, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?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\ErrorHandler\ErrorEnhancer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
use Symfony\Component\ErrorHandler\Error\ClassNotFoundError;
|
||||
use Symfony\Component\ErrorHandler\Error\FatalError;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ClassNotFoundErrorEnhancer implements ErrorEnhancerInterface
|
||||
{
|
||||
public function enhance(\Throwable $error): ?\Throwable
|
||||
{
|
||||
// Some specific versions of PHP produce a fatal error when extending a not found class.
|
||||
$message = !$error instanceof FatalError ? $error->getMessage() : $error->getError()['message'];
|
||||
if (!preg_match('/^(Class|Interface|Trait) [\'"]([^\'"]+)[\'"] not found$/', $message, $matches)) {
|
||||
return null;
|
||||
}
|
||||
$typeName = strtolower($matches[1]);
|
||||
$fullyQualifiedClassName = $matches[2];
|
||||
|
||||
if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
|
||||
$className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
|
||||
$namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
|
||||
$message = \sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
|
||||
$tail = ' for another namespace?';
|
||||
} else {
|
||||
$className = $fullyQualifiedClassName;
|
||||
$message = \sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
|
||||
$tail = '?';
|
||||
}
|
||||
|
||||
if ($candidates = $this->getClassCandidates($className)) {
|
||||
$tail = array_pop($candidates).'"?';
|
||||
if ($candidates) {
|
||||
$tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
|
||||
} else {
|
||||
$tail = ' for "'.$tail;
|
||||
}
|
||||
}
|
||||
$message .= "\nDid you forget a \"use\" statement".$tail;
|
||||
|
||||
return new ClassNotFoundError($message, $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to guess the full namespace for a given class name.
|
||||
*
|
||||
* By default, it looks for PSR-0 and PSR-4 classes registered via a Symfony or a Composer
|
||||
* autoloader (that should cover all common cases).
|
||||
*
|
||||
* @param string $class A class name (without its namespace)
|
||||
*
|
||||
* Returns an array of possible fully qualified class names
|
||||
*/
|
||||
private function getClassCandidates(string $class): array
|
||||
{
|
||||
if (!\is_array($functions = spl_autoload_functions())) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// find Symfony and Composer autoloaders
|
||||
$classes = [];
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (!\is_array($function)) {
|
||||
continue;
|
||||
}
|
||||
// get class loaders wrapped by DebugClassLoader
|
||||
if ($function[0] instanceof DebugClassLoader) {
|
||||
$function = $function[0]->getClassLoader();
|
||||
|
||||
if (!\is_array($function)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($function[0] instanceof ClassLoader) {
|
||||
foreach ($function[0]->getPrefixes() as $prefix => $paths) {
|
||||
foreach ($paths as $path) {
|
||||
$classes[] = $this->findClassInPath($path, $class, $prefix);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
|
||||
foreach ($paths as $path) {
|
||||
$classes[] = $this->findClassInPath($path, $class, $prefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_unique(array_merge([], ...$classes));
|
||||
}
|
||||
|
||||
private function findClassInPath(string $path, string $class, string $prefix): array
|
||||
{
|
||||
$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path);
|
||||
if (!$path || !is_dir($path)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$classes = [];
|
||||
$filename = $class.'.php';
|
||||
try {
|
||||
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
|
||||
if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
|
||||
$classes[] = $class;
|
||||
}
|
||||
}
|
||||
} catch (\UnexpectedValueException) {
|
||||
// a subdirectory may vanish between listing and recursion (e.g. test fixtures)
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
private function convertFileToClass(string $path, string $file, string $prefix): ?string
|
||||
{
|
||||
$candidates = [
|
||||
// namespaced class
|
||||
$namespacedClass = str_replace([$path.\DIRECTORY_SEPARATOR, '.php', '/'], ['', '', '\\'], $file),
|
||||
// namespaced class (with target dir)
|
||||
$prefix.$namespacedClass,
|
||||
// namespaced class (with target dir and separator)
|
||||
$prefix.'\\'.$namespacedClass,
|
||||
// PEAR class
|
||||
str_replace('\\', '_', $namespacedClass),
|
||||
// PEAR class (with target dir)
|
||||
str_replace('\\', '_', $prefix.$namespacedClass),
|
||||
// PEAR class (with target dir and separator)
|
||||
str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
|
||||
];
|
||||
|
||||
if ($prefix) {
|
||||
$candidates = array_filter($candidates, static fn ($candidate) => str_starts_with($candidate, $prefix));
|
||||
}
|
||||
|
||||
// We cannot use the autoloader here as most of them use require; but if the class
|
||||
// is not found, the new autoloader call will require the file again leading to a
|
||||
// "cannot redeclare class" error.
|
||||
foreach ($candidates as $candidate) {
|
||||
if ($this->classExists($candidate)) {
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
// Symfony may ship some polyfills, like "Normalizer". But if the Intl
|
||||
// extension is already installed, the next require_once will fail with
|
||||
// a compile error because the class is already defined. And this one
|
||||
// does not throw a Throwable. So it's better to skip it here.
|
||||
if (str_contains($file, 'Resources/stubs')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
require_once $file;
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if ($this->classExists($candidate)) {
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function classExists(string $class): bool
|
||||
{
|
||||
return class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?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\ErrorHandler\ErrorEnhancer;
|
||||
|
||||
interface ErrorEnhancerInterface
|
||||
{
|
||||
/**
|
||||
* Returns an \Throwable instance if the class is able to improve the error, null otherwise.
|
||||
*/
|
||||
public function enhance(\Throwable $error): ?\Throwable;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?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\ErrorHandler\ErrorEnhancer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Error\FatalError;
|
||||
use Symfony\Component\ErrorHandler\Error\UndefinedFunctionError;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class UndefinedFunctionErrorEnhancer implements ErrorEnhancerInterface
|
||||
{
|
||||
public function enhance(\Throwable $error): ?\Throwable
|
||||
{
|
||||
if ($error instanceof FatalError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$message = $error->getMessage();
|
||||
$messageLen = \strlen($message);
|
||||
$notFoundSuffix = '()';
|
||||
$notFoundSuffixLen = \strlen($notFoundSuffix);
|
||||
if ($notFoundSuffixLen > $messageLen) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (0 !== substr_compare($message, $notFoundSuffix, -$notFoundSuffixLen)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$prefix = 'Call to undefined function ';
|
||||
$prefixLen = \strlen($prefix);
|
||||
if (!str_starts_with($message, $prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$fullyQualifiedFunctionName = substr($message, $prefixLen, -$notFoundSuffixLen);
|
||||
if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
|
||||
$functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
|
||||
$namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
|
||||
$message = \sprintf('Attempted to call undefined function "%s" from namespace "%s".', $functionName, $namespacePrefix);
|
||||
} else {
|
||||
$functionName = $fullyQualifiedFunctionName;
|
||||
$message = \sprintf('Attempted to call undefined function "%s" from the global namespace.', $functionName);
|
||||
}
|
||||
|
||||
$candidates = [];
|
||||
foreach (get_defined_functions() as $type => $definedFunctionNames) {
|
||||
foreach ($definedFunctionNames as $definedFunctionName) {
|
||||
if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
|
||||
$definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
|
||||
} else {
|
||||
$definedFunctionNameBasename = $definedFunctionName;
|
||||
}
|
||||
|
||||
if ($definedFunctionNameBasename === $functionName) {
|
||||
$candidates[] = '\\'.$definedFunctionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($candidates) {
|
||||
sort($candidates);
|
||||
$last = array_pop($candidates).'"?';
|
||||
if ($candidates) {
|
||||
$candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
|
||||
} else {
|
||||
$candidates = '"'.$last;
|
||||
}
|
||||
$message .= "\nDid you mean to call ".$candidates;
|
||||
}
|
||||
|
||||
return new UndefinedFunctionError($message, $error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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\ErrorHandler\ErrorEnhancer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Error\FatalError;
|
||||
use Symfony\Component\ErrorHandler\Error\UndefinedMethodError;
|
||||
|
||||
/**
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class UndefinedMethodErrorEnhancer implements ErrorEnhancerInterface
|
||||
{
|
||||
public function enhance(\Throwable $error): ?\Throwable
|
||||
{
|
||||
if ($error instanceof FatalError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$message = $error->getMessage();
|
||||
preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $message, $matches);
|
||||
if (!$matches) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$className = $matches[1];
|
||||
$methodName = $matches[2];
|
||||
|
||||
$message = \sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
|
||||
|
||||
if ('' === $methodName || !class_exists($className) || null === $methods = get_class_methods($className)) {
|
||||
// failed to get the class or its methods on which an unknown method was called (for example on an anonymous class)
|
||||
return new UndefinedMethodError($message, $error);
|
||||
}
|
||||
|
||||
$candidates = [];
|
||||
foreach ($methods as $definedMethodName) {
|
||||
$lev = levenshtein($methodName, $definedMethodName);
|
||||
if ($lev <= \strlen($methodName) / 3 || str_contains($definedMethodName, $methodName)) {
|
||||
$candidates[] = $definedMethodName;
|
||||
}
|
||||
}
|
||||
|
||||
if ($candidates) {
|
||||
sort($candidates);
|
||||
$last = array_pop($candidates).'"?';
|
||||
if ($candidates) {
|
||||
$candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
|
||||
} else {
|
||||
$candidates = '"'.$last;
|
||||
}
|
||||
|
||||
$message .= "\nDid you mean to call ".$candidates;
|
||||
}
|
||||
|
||||
return new UndefinedMethodError($message, $error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,731 @@
|
||||
<?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\ErrorHandler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\ErrorHandler\Error\FatalError;
|
||||
use Symfony\Component\ErrorHandler\Error\MaxExecutionTimeError;
|
||||
use Symfony\Component\ErrorHandler\Error\OutOfMemoryError;
|
||||
use Symfony\Component\ErrorHandler\ErrorEnhancer\ClassNotFoundErrorEnhancer;
|
||||
use Symfony\Component\ErrorHandler\ErrorEnhancer\ErrorEnhancerInterface;
|
||||
use Symfony\Component\ErrorHandler\ErrorEnhancer\UndefinedFunctionErrorEnhancer;
|
||||
use Symfony\Component\ErrorHandler\ErrorEnhancer\UndefinedMethodErrorEnhancer;
|
||||
use Symfony\Component\ErrorHandler\ErrorRenderer\CliErrorRenderer;
|
||||
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
|
||||
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
|
||||
|
||||
/**
|
||||
* A generic ErrorHandler for the PHP engine.
|
||||
*
|
||||
* Provides five bit fields that control how errors are handled:
|
||||
* - thrownErrors: errors thrown as \ErrorException
|
||||
* - loggedErrors: logged errors, when not @-silenced
|
||||
* - scopedErrors: errors thrown or logged with their local context
|
||||
* - tracedErrors: errors logged with their stack trace
|
||||
* - screamedErrors: never @-silenced errors
|
||||
*
|
||||
* Each error level can be logged by a dedicated PSR-3 logger object.
|
||||
* Screaming only applies to logging.
|
||||
* Throwing takes precedence over logging.
|
||||
* Uncaught exceptions are logged as E_ERROR.
|
||||
* E_DEPRECATED and E_USER_DEPRECATED levels never throw.
|
||||
* E_RECOVERABLE_ERROR and E_USER_ERROR levels always throw.
|
||||
* Non catchable errors that can be detected at shutdown time are logged when the scream bit field allows so.
|
||||
* As errors have a performance cost, repeated errors are all logged, so that the developer
|
||||
* can see them and weight them as more important to fix than others of the same level.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class ErrorHandler
|
||||
{
|
||||
private array $levels = [
|
||||
\E_DEPRECATED => 'Deprecated',
|
||||
\E_USER_DEPRECATED => 'User Deprecated',
|
||||
\E_NOTICE => 'Notice',
|
||||
\E_USER_NOTICE => 'User Notice',
|
||||
\E_WARNING => 'Warning',
|
||||
\E_USER_WARNING => 'User Warning',
|
||||
\E_COMPILE_WARNING => 'Compile Warning',
|
||||
\E_CORE_WARNING => 'Core Warning',
|
||||
\E_USER_ERROR => 'User Error',
|
||||
\E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
|
||||
\E_COMPILE_ERROR => 'Compile Error',
|
||||
\E_PARSE => 'Parse Error',
|
||||
\E_ERROR => 'Error',
|
||||
\E_CORE_ERROR => 'Core Error',
|
||||
];
|
||||
|
||||
private array $loggers = [
|
||||
\E_DEPRECATED => [null, LogLevel::INFO],
|
||||
\E_USER_DEPRECATED => [null, LogLevel::INFO],
|
||||
\E_NOTICE => [null, LogLevel::ERROR],
|
||||
\E_USER_NOTICE => [null, LogLevel::ERROR],
|
||||
\E_WARNING => [null, LogLevel::ERROR],
|
||||
\E_USER_WARNING => [null, LogLevel::ERROR],
|
||||
\E_COMPILE_WARNING => [null, LogLevel::ERROR],
|
||||
\E_CORE_WARNING => [null, LogLevel::ERROR],
|
||||
\E_USER_ERROR => [null, LogLevel::CRITICAL],
|
||||
\E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL],
|
||||
\E_COMPILE_ERROR => [null, LogLevel::CRITICAL],
|
||||
\E_PARSE => [null, LogLevel::CRITICAL],
|
||||
\E_ERROR => [null, LogLevel::CRITICAL],
|
||||
\E_CORE_ERROR => [null, LogLevel::CRITICAL],
|
||||
];
|
||||
|
||||
private int $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED
|
||||
private int $scopedErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED
|
||||
private int $tracedErrors = 0x77FB; // E_ALL - E_STRICT - E_PARSE
|
||||
private int $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
|
||||
private int $loggedErrors = 0;
|
||||
private \Closure $configureException;
|
||||
|
||||
private bool $isRecursive = false;
|
||||
private bool $isRoot = false;
|
||||
/** @var callable|null */
|
||||
private $exceptionHandler;
|
||||
private ?BufferingLogger $bootstrappingLogger = null;
|
||||
|
||||
private static ?string $reservedMemory = null;
|
||||
private static array $silencedErrorCache = [];
|
||||
private static int $silencedErrorCount = 0;
|
||||
private static int $exitCode = 0;
|
||||
|
||||
/**
|
||||
* Registers the error handler.
|
||||
*/
|
||||
public static function register(?self $handler = null, bool $replace = true): self
|
||||
{
|
||||
if (null === self::$reservedMemory) {
|
||||
self::$reservedMemory = str_repeat('x', 32768);
|
||||
register_shutdown_function(self::handleFatalError(...));
|
||||
}
|
||||
|
||||
if ($handlerIsNew = null === $handler) {
|
||||
$handler = new static();
|
||||
}
|
||||
|
||||
if (null === $prev = get_error_handler()) {
|
||||
// Specifying the error types earlier would expose us to https://bugs.php.net/63206
|
||||
set_error_handler([$handler, 'handleError'], $handler->thrownErrors | $handler->loggedErrors);
|
||||
$handler->isRoot = true;
|
||||
} else {
|
||||
set_error_handler([$handler, 'handleError']);
|
||||
}
|
||||
|
||||
if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
|
||||
$handler = $prev[0];
|
||||
$replace = false;
|
||||
}
|
||||
if (!$replace && $prev) {
|
||||
restore_error_handler();
|
||||
$handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
|
||||
} else {
|
||||
$handlerIsRegistered = true;
|
||||
}
|
||||
if (\is_array($prev = set_exception_handler([$handler, 'handleException'])) && $prev[0] instanceof self) {
|
||||
restore_exception_handler();
|
||||
if (!$handlerIsRegistered) {
|
||||
$handler = $prev[0];
|
||||
} elseif ($handler !== $prev[0] && $replace) {
|
||||
set_exception_handler([$handler, 'handleException']);
|
||||
$p = $prev[0]->setExceptionHandler(null);
|
||||
$handler->setExceptionHandler($p);
|
||||
$prev[0]->setExceptionHandler($p);
|
||||
}
|
||||
} else {
|
||||
$handler->setExceptionHandler($prev ?? [$handler, 'renderException']);
|
||||
}
|
||||
|
||||
$handler->throwAt(\E_ALL & $handler->thrownErrors, true);
|
||||
|
||||
return $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls a function and turns any PHP error into \ErrorException.
|
||||
*
|
||||
* @param-immediately-invoked-callable $function
|
||||
*
|
||||
* @throws \ErrorException When $function(...$arguments) triggers a PHP error
|
||||
*/
|
||||
public static function call(callable $function, mixed ...$arguments): mixed
|
||||
{
|
||||
set_error_handler(static function (int $type, string $message, string $file, int $line) {
|
||||
if (__FILE__ === $file) {
|
||||
$trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
$file = $trace[2]['file'] ?? $file;
|
||||
$line = $trace[2]['line'] ?? $line;
|
||||
}
|
||||
|
||||
throw new \ErrorException($message, 0, $type, $file, $line);
|
||||
});
|
||||
|
||||
try {
|
||||
return $function(...$arguments);
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
?BufferingLogger $bootstrappingLogger = null,
|
||||
private bool $debug = false,
|
||||
) {
|
||||
if ($bootstrappingLogger) {
|
||||
$this->bootstrappingLogger = $bootstrappingLogger;
|
||||
$this->setDefaultLogger($bootstrappingLogger);
|
||||
}
|
||||
$traceReflector = new \ReflectionProperty(\Exception::class, 'trace');
|
||||
$this->configureException = \Closure::bind(static function ($e, $trace, $file = null, $line = null) use ($traceReflector) {
|
||||
$traceReflector->setValue($e, $trace);
|
||||
$e->file = $file ?? $e->file;
|
||||
$e->line = $line ?? $e->line;
|
||||
}, null, new class extends \Exception {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a logger to non assigned errors levels.
|
||||
*
|
||||
* @param LoggerInterface $logger A PSR-3 logger to put as default for the given levels
|
||||
* @param array|int|null $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
|
||||
* @param bool $replace Whether to replace or not any existing logger
|
||||
*/
|
||||
public function setDefaultLogger(LoggerInterface $logger, array|int|null $levels = \E_ALL, bool $replace = false): void
|
||||
{
|
||||
$loggers = [];
|
||||
|
||||
if (\is_array($levels)) {
|
||||
foreach ($levels as $type => $logLevel) {
|
||||
if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
|
||||
$loggers[$type] = [$logger, $logLevel];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$levels ??= \E_ALL;
|
||||
foreach ($this->loggers as $type => $log) {
|
||||
if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
|
||||
$log[0] = $logger;
|
||||
$loggers[$type] = $log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->setLoggers($loggers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a logger for each error level.
|
||||
*
|
||||
* @param array $loggers Error levels to [LoggerInterface|null, LogLevel::*] map
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setLoggers(array $loggers): array
|
||||
{
|
||||
$prevLogged = $this->loggedErrors;
|
||||
$prev = $this->loggers;
|
||||
$flush = [];
|
||||
|
||||
foreach ($loggers as $type => $log) {
|
||||
if (!isset($prev[$type])) {
|
||||
throw new \InvalidArgumentException('Unknown error type: '.$type);
|
||||
}
|
||||
if (!\is_array($log)) {
|
||||
$log = [$log];
|
||||
} elseif (!\array_key_exists(0, $log)) {
|
||||
throw new \InvalidArgumentException('No logger provided.');
|
||||
}
|
||||
if (null === $log[0]) {
|
||||
$this->loggedErrors &= ~$type;
|
||||
} elseif ($log[0] instanceof LoggerInterface) {
|
||||
$this->loggedErrors |= $type;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid logger provided.');
|
||||
}
|
||||
$this->loggers[$type] = $log + $prev[$type];
|
||||
|
||||
if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
|
||||
$flush[$type] = $type;
|
||||
}
|
||||
}
|
||||
$this->reRegister($prevLogged | $this->thrownErrors);
|
||||
|
||||
if ($flush) {
|
||||
foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
|
||||
$type = ThrowableUtils::getSeverity($log[2]['exception']);
|
||||
if (!isset($flush[$type])) {
|
||||
$this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
|
||||
} elseif ($this->loggers[$type][0]) {
|
||||
$this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
public function setExceptionHandler(?callable $handler): ?callable
|
||||
{
|
||||
$prev = $this->exceptionHandler;
|
||||
$this->exceptionHandler = $handler;
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP error levels that throw an exception when a PHP error occurs.
|
||||
*
|
||||
* @param int $levels A bit field of E_* constants for thrown errors
|
||||
* @param bool $replace Replace or amend the previous value
|
||||
*/
|
||||
public function throwAt(int $levels, bool $replace = false): int
|
||||
{
|
||||
$prev = $this->thrownErrors;
|
||||
$this->thrownErrors = ($levels | \E_RECOVERABLE_ERROR | \E_USER_ERROR) & ~\E_USER_DEPRECATED & ~\E_DEPRECATED;
|
||||
if (!$replace) {
|
||||
$this->thrownErrors |= $prev;
|
||||
}
|
||||
$this->reRegister($prev | $this->loggedErrors);
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP error levels for which local variables are preserved.
|
||||
*
|
||||
* @param int $levels A bit field of E_* constants for scoped errors
|
||||
* @param bool $replace Replace or amend the previous value
|
||||
*/
|
||||
public function scopeAt(int $levels, bool $replace = false): int
|
||||
{
|
||||
$prev = $this->scopedErrors;
|
||||
$this->scopedErrors = $levels;
|
||||
if (!$replace) {
|
||||
$this->scopedErrors |= $prev;
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PHP error levels for which the stack trace is preserved.
|
||||
*
|
||||
* @param int $levels A bit field of E_* constants for traced errors
|
||||
* @param bool $replace Replace or amend the previous value
|
||||
*/
|
||||
public function traceAt(int $levels, bool $replace = false): int
|
||||
{
|
||||
$prev = $this->tracedErrors;
|
||||
$this->tracedErrors = $levels;
|
||||
if (!$replace) {
|
||||
$this->tracedErrors |= $prev;
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error levels where the @-operator is ignored.
|
||||
*
|
||||
* @param int $levels A bit field of E_* constants for screamed errors
|
||||
* @param bool $replace Replace or amend the previous value
|
||||
*/
|
||||
public function screamAt(int $levels, bool $replace = false): int
|
||||
{
|
||||
$prev = $this->screamedErrors;
|
||||
$this->screamedErrors = $levels;
|
||||
if (!$replace) {
|
||||
$this->screamedErrors |= $prev;
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-registers as a PHP error handler if levels changed.
|
||||
*/
|
||||
private function reRegister(int $prev): void
|
||||
{
|
||||
if ($prev !== ($this->thrownErrors | $this->loggedErrors)) {
|
||||
$handler = get_error_handler();
|
||||
$handler = \is_array($handler) ? $handler[0] : null;
|
||||
if ($handler === $this) {
|
||||
restore_error_handler();
|
||||
if ($this->isRoot) {
|
||||
set_error_handler([$this, 'handleError'], $this->thrownErrors | $this->loggedErrors);
|
||||
} else {
|
||||
set_error_handler([$this, 'handleError']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles errors by filtering then logging them according to the configured bit fields.
|
||||
*
|
||||
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
|
||||
*
|
||||
* @throws \ErrorException When $this->thrownErrors requests so
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function handleError(int $type, string $message, string $file, int $line): bool
|
||||
{
|
||||
if (\E_WARNING === $type && '"' === $message[0] && str_contains($message, '" targeting switch is equivalent to "break')) {
|
||||
$type = \E_DEPRECATED;
|
||||
}
|
||||
|
||||
// Level is the current error reporting level to manage silent error.
|
||||
$level = error_reporting();
|
||||
$silenced = 0 === ($level & $type);
|
||||
// Strong errors are not authorized to be silenced.
|
||||
$level |= \E_RECOVERABLE_ERROR | \E_USER_ERROR | \E_DEPRECATED | \E_USER_DEPRECATED;
|
||||
$log = $this->loggedErrors & $type;
|
||||
$throw = $this->thrownErrors & $type & $level;
|
||||
$type &= $level | $this->screamedErrors;
|
||||
|
||||
// Never throw on warnings triggered by assert()
|
||||
if (\E_WARNING === $type && 'a' === $message[0] && 0 === strncmp($message, 'assert(): ', 10)) {
|
||||
$throw = 0;
|
||||
}
|
||||
|
||||
if (!$type || (!$log && !$throw)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
|
||||
if (!$throw && !($type & $level)) {
|
||||
if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) {
|
||||
$lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 5), $type, $file, $line, false) : [];
|
||||
$errorAsException = new SilencedErrorContext($type, $file, $line, isset($lightTrace[1]) ? [$lightTrace[0]] : $lightTrace);
|
||||
} elseif (isset(self::$silencedErrorCache[$id][$message])) {
|
||||
$lightTrace = null;
|
||||
$errorAsException = self::$silencedErrorCache[$id][$message];
|
||||
++$errorAsException->count;
|
||||
} else {
|
||||
$lightTrace = [];
|
||||
$errorAsException = null;
|
||||
}
|
||||
|
||||
if (100 < ++self::$silencedErrorCount) {
|
||||
self::$silencedErrorCache = $lightTrace = [];
|
||||
self::$silencedErrorCount = 1;
|
||||
}
|
||||
if ($errorAsException) {
|
||||
self::$silencedErrorCache[$id][$message] = $errorAsException;
|
||||
}
|
||||
if (null === $lightTrace) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (str_contains($message, "@anonymous\0")) {
|
||||
$message = $this->parseAnonymousClass($message);
|
||||
$logMessage = $this->levels[$type].': '.$message;
|
||||
}
|
||||
|
||||
$errorAsException = new \ErrorException($logMessage, 0, $type, $file, $line);
|
||||
|
||||
if ($throw || $this->tracedErrors & $type) {
|
||||
$backtrace = $errorAsException->getTrace();
|
||||
$backtrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw);
|
||||
($this->configureException)($errorAsException, $backtrace, $file, $line);
|
||||
} else {
|
||||
($this->configureException)($errorAsException, []);
|
||||
}
|
||||
}
|
||||
|
||||
if ($throw) {
|
||||
throw $errorAsException;
|
||||
}
|
||||
|
||||
if ($this->isRecursive) {
|
||||
$log = 0;
|
||||
} else {
|
||||
try {
|
||||
$this->isRecursive = true;
|
||||
$level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG;
|
||||
$this->loggers[$type][0]->log($level, $logMessage, $errorAsException ? ['exception' => $errorAsException] : []);
|
||||
} finally {
|
||||
$this->isRecursive = false;
|
||||
}
|
||||
}
|
||||
|
||||
return !$silenced && $type && $log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles an exception by logging then forwarding it to another handler.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function handleException(\Throwable $exception): void
|
||||
{
|
||||
$handlerException = null;
|
||||
|
||||
if (!$exception instanceof FatalError) {
|
||||
self::$exitCode = 255;
|
||||
|
||||
$type = ThrowableUtils::getSeverity($exception);
|
||||
} else {
|
||||
$type = $exception->getError()['type'];
|
||||
}
|
||||
|
||||
if ($this->loggedErrors & $type) {
|
||||
if (str_contains($message = $exception->getMessage(), "@anonymous\0")) {
|
||||
$message = $this->parseAnonymousClass($message);
|
||||
}
|
||||
|
||||
if ($exception instanceof FatalError) {
|
||||
$message = 'Fatal '.$message;
|
||||
} elseif ($exception instanceof \Error) {
|
||||
$message = 'Uncaught Error: '.$message;
|
||||
} elseif ($exception instanceof \ErrorException) {
|
||||
$message = 'Uncaught '.$message;
|
||||
} else {
|
||||
$message = 'Uncaught Exception: '.$message;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->loggers[$type][0]->log($this->loggers[$type][1], $message, ['exception' => $exception]);
|
||||
} catch (\Throwable $handlerException) {
|
||||
}
|
||||
}
|
||||
|
||||
$exception = $this->enhanceError($exception);
|
||||
|
||||
$exceptionHandler = $this->exceptionHandler;
|
||||
$this->exceptionHandler = [$this, 'renderException'];
|
||||
|
||||
if (null === $exceptionHandler || $exceptionHandler === $this->exceptionHandler) {
|
||||
$this->exceptionHandler = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (null !== $exceptionHandler) {
|
||||
$exceptionHandler($exception);
|
||||
|
||||
return;
|
||||
}
|
||||
$handlerException ??= $exception;
|
||||
} catch (\Throwable $handlerException) {
|
||||
}
|
||||
if ($exception === $handlerException && null === $this->exceptionHandler) {
|
||||
self::$reservedMemory = null; // Disable the fatal error handler
|
||||
throw $exception; // Give back $exception to the native handler
|
||||
}
|
||||
|
||||
$loggedErrors = $this->loggedErrors;
|
||||
if ($exception === $handlerException) {
|
||||
$this->loggedErrors &= ~$type;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->handleException($handlerException);
|
||||
} finally {
|
||||
$this->loggedErrors = $loggedErrors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown registered function for handling PHP fatal errors.
|
||||
*
|
||||
* @param array|null $error An array as returned by error_get_last()
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function handleFatalError(?array $error = null): void
|
||||
{
|
||||
if (null === self::$reservedMemory) {
|
||||
return;
|
||||
}
|
||||
|
||||
$handler = self::$reservedMemory = null;
|
||||
$handlers = [];
|
||||
$previousHandler = null;
|
||||
$sameHandlerLimit = 10;
|
||||
|
||||
while (!\is_array($handler) || !$handler[0] instanceof self) {
|
||||
$handler = set_exception_handler('is_int');
|
||||
restore_exception_handler();
|
||||
|
||||
if (!$handler) {
|
||||
break;
|
||||
}
|
||||
restore_exception_handler();
|
||||
|
||||
if ($handler !== $previousHandler) {
|
||||
array_unshift($handlers, $handler);
|
||||
$previousHandler = $handler;
|
||||
} elseif (0 === --$sameHandlerLimit) {
|
||||
$handler = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ($handlers as $h) {
|
||||
set_exception_handler($h);
|
||||
}
|
||||
if (!$handler) {
|
||||
if (null === $error && $exitCode = self::$exitCode) {
|
||||
register_shutdown_function('register_shutdown_function', static function () use ($exitCode) { exit($exitCode); });
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if ($handler !== $h) {
|
||||
$handler[0]->setExceptionHandler($h);
|
||||
}
|
||||
$handler = $handler[0];
|
||||
$handlers = [];
|
||||
|
||||
if ($exit = null === $error) {
|
||||
$error = error_get_last();
|
||||
}
|
||||
|
||||
if ($error && $error['type'] &= \E_PARSE | \E_ERROR | \E_CORE_ERROR | \E_COMPILE_ERROR) {
|
||||
// Let's not throw anymore but keep logging
|
||||
$handler->throwAt(0, true);
|
||||
$trace = $error['backtrace'] ?? null;
|
||||
|
||||
if (str_starts_with($error['message'], 'Allowed memory') || str_starts_with($error['message'], 'Out of memory')) {
|
||||
$fatalError = new OutOfMemoryError($handler->levels[$error['type']].': '.$error['message'], 0, $error, 2, false, $trace);
|
||||
} elseif (str_starts_with($error['message'], 'Maximum execution time of')) {
|
||||
$fatalError = new MaxExecutionTimeError($handler->levels[$error['type']].': '.$error['message'], 0, $error, 2, false, $trace);
|
||||
} else {
|
||||
$fatalError = new FatalError($handler->levels[$error['type']].': '.$error['message'], 0, $error, 2, true, $trace);
|
||||
}
|
||||
} else {
|
||||
$fatalError = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (null !== $fatalError) {
|
||||
self::$exitCode = 255;
|
||||
$handler->handleException($fatalError);
|
||||
}
|
||||
} catch (FatalError) {
|
||||
// Ignore this re-throw
|
||||
}
|
||||
|
||||
if ($exit && $exitCode = self::$exitCode) {
|
||||
register_shutdown_function('register_shutdown_function', static function () use ($exitCode) { exit($exitCode); });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the given exception.
|
||||
*
|
||||
* As this method is mainly called during boot where nothing is yet available,
|
||||
* the output is always either HTML or CLI depending where PHP runs.
|
||||
*/
|
||||
private function renderException(\Throwable $exception): void
|
||||
{
|
||||
$renderer = \in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) ? new CliErrorRenderer() : new HtmlErrorRenderer($this->debug);
|
||||
|
||||
$flattenedException = $renderer->render($exception);
|
||||
|
||||
if (!headers_sent() && !$exception instanceof OutOfMemoryError && !$exception instanceof MaxExecutionTimeError) {
|
||||
http_response_code($flattenedException->getStatusCode());
|
||||
|
||||
foreach ($flattenedException->getHeaders() as $name => $value) {
|
||||
header($name.': '.$value, false);
|
||||
}
|
||||
}
|
||||
|
||||
echo $flattenedException->getAsString();
|
||||
}
|
||||
|
||||
public function enhanceError(\Throwable $exception): \Throwable
|
||||
{
|
||||
if ($exception instanceof OutOfMemoryError || $exception instanceof MaxExecutionTimeError) {
|
||||
return $exception;
|
||||
}
|
||||
|
||||
foreach ($this->getErrorEnhancers() as $errorEnhancer) {
|
||||
if ($e = $errorEnhancer->enhance($exception)) {
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method if you want to define more error enhancers.
|
||||
*
|
||||
* @return ErrorEnhancerInterface[]
|
||||
*/
|
||||
protected function getErrorEnhancers(): iterable
|
||||
{
|
||||
return [
|
||||
new UndefinedFunctionErrorEnhancer(),
|
||||
new UndefinedMethodErrorEnhancer(),
|
||||
new ClassNotFoundErrorEnhancer(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the trace by removing function arguments and the frames added by the error handler and DebugClassLoader.
|
||||
*/
|
||||
private function cleanTrace(array $backtrace, int $type, string &$file, int &$line, bool $throw): array
|
||||
{
|
||||
$lightTrace = $backtrace;
|
||||
|
||||
for ($i = 0; isset($backtrace[$i]); ++$i) {
|
||||
if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
|
||||
$lightTrace = \array_slice($lightTrace, 1 + $i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (\E_USER_DEPRECATED === $type) {
|
||||
for ($i = 0; isset($lightTrace[$i]); ++$i) {
|
||||
if (!isset($lightTrace[$i]['file'], $lightTrace[$i]['line'], $lightTrace[$i]['function'])) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($lightTrace[$i]['class']) && 'trigger_deprecation' === $lightTrace[$i]['function']) {
|
||||
$file = $lightTrace[$i]['file'];
|
||||
$line = $lightTrace[$i]['line'];
|
||||
$lightTrace = \array_slice($lightTrace, 1 + $i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (class_exists(DebugClassLoader::class, false)) {
|
||||
for ($i = \count($lightTrace) - 2; 0 < $i; --$i) {
|
||||
if (DebugClassLoader::class === ($lightTrace[$i]['class'] ?? null)) {
|
||||
array_splice($lightTrace, --$i, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!($throw || $this->scopedErrors & $type)) {
|
||||
for ($i = 0; isset($lightTrace[$i]); ++$i) {
|
||||
unset($lightTrace[$i]['args'], $lightTrace[$i]['object']);
|
||||
}
|
||||
}
|
||||
|
||||
return $lightTrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the error message by removing the anonymous class notation
|
||||
* and using the parent class instead if possible.
|
||||
*/
|
||||
private function parseAnonymousClass(string $message): string
|
||||
{
|
||||
return preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(CliDumper::class);
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CliErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$cloner = new VarCloner();
|
||||
$dumper = new class extends CliDumper {
|
||||
protected function supportsColors(): bool
|
||||
{
|
||||
$outputStream = $this->outputStream;
|
||||
$this->outputStream = fopen('php://stdout', 'w');
|
||||
|
||||
try {
|
||||
return parent::supportsColors();
|
||||
} finally {
|
||||
$this->outputStream = $outputStream;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return FlattenException::createFromThrowable($exception)
|
||||
->setAsString($dumper->dump($cloner->cloneVar($exception), true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* Formats an exception to be used as response content.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
interface ErrorRendererInterface
|
||||
{
|
||||
public const IDE_LINK_FORMATS = [
|
||||
'textmate' => 'txmt://open?url=file://%f&line=%l',
|
||||
'macvim' => 'mvim://open?url=file://%f&line=%l',
|
||||
'emacs' => 'emacs://open?url=file://%f&line=%l',
|
||||
'sublime' => 'subl://open?url=file://%f&line=%l',
|
||||
'phpstorm' => 'phpstorm://open?file=%f&line=%l',
|
||||
'atom' => 'atom://core/open/file?filename=%f&line=%l',
|
||||
'vscode' => 'vscode://file/%f:%l',
|
||||
];
|
||||
|
||||
/**
|
||||
* Renders a Throwable as a FlattenException.
|
||||
*/
|
||||
public function render(\Throwable $exception): FlattenException;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
<?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\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
/**
|
||||
* Formats debug file links.
|
||||
*
|
||||
* @author Jérémy Romey <jeremy@free-agent.fr>
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class FileLinkFormatter
|
||||
{
|
||||
private array|false $fileLinkFormat;
|
||||
|
||||
/**
|
||||
* @param string|\Closure $urlFormat The URL format, or a closure that returns it on-demand
|
||||
*/
|
||||
public function __construct(
|
||||
string|array|null $fileLinkFormat = null,
|
||||
private ?RequestStack $requestStack = null,
|
||||
private ?string $baseDir = null,
|
||||
private string|\Closure|null $urlFormat = null,
|
||||
) {
|
||||
$fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? '';
|
||||
|
||||
if (!\is_array($f = $fileLinkFormat)) {
|
||||
$f = (ErrorRendererInterface::IDE_LINK_FORMATS[$f] ?? $f) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l';
|
||||
$i = strpos($f, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
|
||||
$fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);
|
||||
}
|
||||
|
||||
$this->fileLinkFormat = $fileLinkFormat;
|
||||
}
|
||||
|
||||
public function format(string $file, int $line): string|false
|
||||
{
|
||||
if ($fmt = $this->getFileLinkFormat()) {
|
||||
for ($i = 1; isset($fmt[$i]); ++$i) {
|
||||
if (str_starts_with($file, $k = $fmt[$i++])) {
|
||||
$file = substr_replace($file, $fmt[$i], 0, \strlen($k));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strtr($fmt[0], ['%f' => $file, '%l' => $line]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
$this->fileLinkFormat = $this->getFileLinkFormat();
|
||||
|
||||
return ['fileLinkFormat' => $this->fileLinkFormat];
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public static function generateUrlFormat(UrlGeneratorInterface $router, string $routeName, string $queryString): ?string
|
||||
{
|
||||
try {
|
||||
return $router->generate($routeName).$queryString;
|
||||
} catch (\Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function getFileLinkFormat(): array|false
|
||||
{
|
||||
if ($this->fileLinkFormat) {
|
||||
return $this->fileLinkFormat;
|
||||
}
|
||||
|
||||
if ($this->requestStack && $this->baseDir && $this->urlFormat) {
|
||||
$request = $this->requestStack->getMainRequest();
|
||||
|
||||
if ($request instanceof Request && (!$this->urlFormat instanceof \Closure || $this->urlFormat = ($this->urlFormat)())) {
|
||||
return [
|
||||
$request->getSchemeAndHttpHost().$this->urlFormat,
|
||||
$this->baseDir.\DIRECTORY_SEPARATOR, '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?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\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
|
||||
/**
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
class HtmlErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
private const GHOST_ADDONS = [
|
||||
'02-14' => self::GHOST_HEART,
|
||||
'02-29' => self::GHOST_PLUS,
|
||||
'10-18' => self::GHOST_GIFT,
|
||||
];
|
||||
|
||||
private const GHOST_GIFT = 'M124.00534057617188,5.3606138080358505 C124.40059661865234,4.644828304648399 125.1237564086914,3.712414965033531 123.88127899169922,3.487462028861046 C123.53517150878906,3.3097832053899765 123.18894958496094,2.9953975528478622 122.8432846069336,3.345616325736046 C122.07421112060547,3.649444565176964 121.40750122070312,4.074306473135948 122.2164306640625,4.869479164481163 C122.57514953613281,5.3830065578222275 122.90142822265625,6.503447040915489 123.3077621459961,6.626829609274864 C123.55027770996094,6.210384353995323 123.7774658203125,5.785196766257286 124.00534057617188,5.3606138080358505 zM122.30630493164062,7.336987480521202 C121.60028076171875,6.076864704489708 121.03211975097656,4.72498320043087 120.16796875,3.562500938773155 C119.11695098876953,2.44033907353878 117.04605865478516,2.940566048026085 116.57544708251953,4.387995228171349 C115.95028686523438,5.819030746817589 117.2991714477539,7.527640804648399 118.826171875,7.348545059561729 C119.98493194580078,7.367936596274376 121.15027618408203,7.420116886496544 122.30630493164062,7.336987480521202 zM128.1732177734375,7.379541382193565 C129.67486572265625,7.17823551595211 130.53842163085938,5.287807449698448 129.68344116210938,4.032590612769127 C128.92578125,2.693056806921959 126.74605560302734,2.6463639587163925 125.98509216308594,4.007616028189659 C125.32617950439453,5.108129009604454 124.75428009033203,6.258124336600304 124.14962768554688,7.388818249106407 C125.48638916015625,7.465229496359825 126.8357162475586,7.447416767477989 128.1732177734375,7.379541382193565 zM130.6601104736328,8.991325363516808 C131.17202758789062,8.540884003043175 133.1543731689453,8.009847149252892 131.65304565429688,7.582054600119591 C131.2811279296875,7.476506695151329 130.84751892089844,6.99234913289547 130.5132598876953,7.124847874045372 C129.78744506835938,8.02728746831417 128.67140197753906,8.55669592320919 127.50616455078125,8.501235947012901 C127.27806091308594,8.576229080557823 126.11459350585938,8.38720129430294 126.428955078125,8.601900085806847 C127.25099182128906,9.070617660880089 128.0523223876953,9.579657539725304 128.902587890625,9.995706543326378 C129.49813842773438,9.678531631827354 130.0761260986328,9.329126343131065 130.6601104736328,8.991325363516808 zM118.96446990966797,9.246344551444054 C119.4022445678711,8.991325363516808 119.84001922607422,8.736305221915245 120.27779388427734,8.481284126639366 C118.93965911865234,8.414779648184776 117.40827941894531,8.607666000723839 116.39698791503906,7.531384453177452 C116.11186981201172,7.212117180228233 115.83845520019531,6.846597656607628 115.44329071044922,7.248530372977257 C114.96995544433594,7.574637398123741 113.5140609741211,7.908811077475548 114.63501739501953,8.306883797049522 C115.61112976074219,8.883499130606651 116.58037567138672,9.474181160330772 117.58061218261719,10.008124336600304 C118.05723571777344,9.784612640738487 118.50651550292969,9.5052699893713 118.96446990966797,9.246344551444054 zM125.38018035888672,12.091858848929405 C125.9474868774414,11.636047348380089 127.32159423828125,11.201767906546593 127.36749267578125,10.712632164359093 C126.08487701416016,9.974547371268272 124.83960723876953,9.152772888541222 123.49772644042969,8.528907760977745 C123.03594207763672,8.353693947196007 122.66152954101562,8.623294815421104 122.28982543945312,8.857431396842003 C121.19065856933594,9.51122473180294 120.06505584716797,10.12446115911007 119.00167083740234,10.835315689444542 C120.39238739013672,11.69529627263546 121.79983520507812,12.529837593436241 123.22095489501953,13.338589653372765 C123.94580841064453,12.932025894522667 124.66128540039062,12.508862480521202 125.38018035888672,12.091858848929405 zM131.07164001464844,13.514615997672081 C131.66018676757812,13.143282875418663 132.2487335205078,12.771927818655968 132.8372802734375,12.400571808218956 C132.8324737548828,11.156818374991417 132.8523406982422,9.912529930472374 132.81829833984375,8.669195160269737 C131.63046264648438,9.332009300589561 130.45948791503906,10.027913078665733 129.30828857421875,10.752535805106163 C129.182373046875,12.035354599356651 129.24623107910156,13.33940313756466 129.27359008789062,14.628684982657433 C129.88104248046875,14.27079389989376 130.4737548828125,13.888019546866417 131.07164001464844,13.514640793204308 zM117.26847839355469,12.731024727225304 C117.32825469970703,11.67083452641964 117.45709991455078,10.46224020421505 116.17853546142578,10.148179039359093 C115.37110900878906,9.77159021794796 114.25194549560547,8.806716904044151 113.62991333007812,8.81639002263546 C113.61052703857422,10.0110072940588 113.62078857421875,11.20585821568966 113.61869049072266,12.400571808218956 C114.81139373779297,13.144886955618858 115.98292541503906,13.925040230154991 117.20137023925781,14.626662239432335 C117.31951141357422,14.010867103934288 117.24227905273438,13.35805033147335 117.26847839355469,12.731024727225304 zM125.80937957763672,16.836034759879112 C126.51483917236328,16.390663132071495 127.22030Line truncated
|
||||
private const GHOST_HEART = 'M125.91386369681868,8.305165958366445 C128.95033202169043,-0.40540639102854037 140.8469835342744,8.305165958366445 125.91386369681868,19.504526138305664 C110.98208663272044,8.305165958366445 122.87795231771452,-0.40540639102854037 125.91386369681868,8.305165958366445 z';
|
||||
private const GHOST_PLUS = 'M111.36824226379395,8.969108581542969 L118.69175148010254,8.969108581542969 L118.69175148010254,1.6455793380737305 L126.20429420471191,1.6455793380737305 L126.20429420471191,8.969108581542969 L133.52781105041504,8.969108581542969 L133.52781105041504,16.481630325317383 L126.20429420471191,16.481630325317383 L126.20429420471191,23.805158615112305 L118.69175148010254,23.805158615112305 L118.69175148010254,16.481630325317383 L111.36824226379395,16.481630325317383 z';
|
||||
|
||||
private bool|\Closure $debug;
|
||||
private string $charset;
|
||||
private FileLinkFormatter $fileLinkFormat;
|
||||
private string|\Closure $outputBuffer;
|
||||
|
||||
private static string $template = 'views/error.html.php';
|
||||
|
||||
/**
|
||||
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
|
||||
* @param string|callable $outputBuffer The output buffer as a string or a callable that should return it
|
||||
*/
|
||||
public function __construct(
|
||||
bool|callable $debug = false,
|
||||
?string $charset = null,
|
||||
string|FileLinkFormatter|null $fileLinkFormat = null,
|
||||
private ?string $projectDir = null,
|
||||
string|callable $outputBuffer = '',
|
||||
private ?LoggerInterface $logger = null,
|
||||
) {
|
||||
$this->debug = \is_bool($debug) ? $debug : $debug(...);
|
||||
$this->charset = $charset ?: (\ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->fileLinkFormat = $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : new FileLinkFormatter($fileLinkFormat);
|
||||
$this->outputBuffer = \is_string($outputBuffer) ? $outputBuffer : $outputBuffer(...);
|
||||
}
|
||||
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$headers = ['Content-Type' => 'text/html; charset='.$this->charset];
|
||||
if (\is_bool($this->debug) ? $this->debug : ($this->debug)($exception)) {
|
||||
$headers['X-Debug-Exception'] = rawurlencode(substr($exception->getMessage(), 0, 2000));
|
||||
$headers['X-Debug-Exception-File'] = rawurlencode($exception->getFile()).':'.$exception->getLine();
|
||||
}
|
||||
|
||||
$exception = FlattenException::createWithDataRepresentation($exception, null, $headers);
|
||||
|
||||
return $exception->setAsString($this->renderException($exception));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTML content associated with the given exception.
|
||||
*/
|
||||
public function getBody(FlattenException $exception): string
|
||||
{
|
||||
return $this->renderException($exception, 'views/exception.html.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stylesheet associated with the given exception.
|
||||
*/
|
||||
public function getStylesheet(): string
|
||||
{
|
||||
if (!$this->debug) {
|
||||
return $this->include('assets/css/error.css');
|
||||
}
|
||||
|
||||
return $this->include('assets/css/exception.css');
|
||||
}
|
||||
|
||||
public static function isDebug(RequestStack $requestStack, bool $debug): \Closure
|
||||
{
|
||||
return static function () use ($requestStack, $debug): bool {
|
||||
if (!$request = $requestStack->getCurrentRequest()) {
|
||||
return $debug;
|
||||
}
|
||||
|
||||
return $debug && $request->attributes->getBoolean('showException', true);
|
||||
};
|
||||
}
|
||||
|
||||
public static function getAndCleanOutputBuffer(RequestStack $requestStack): \Closure
|
||||
{
|
||||
return static function () use ($requestStack): string {
|
||||
if (!$request = $requestStack->getCurrentRequest()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$startObLevel = $request->headers->get('X-Php-Ob-Level', -1);
|
||||
|
||||
if (ob_get_level() <= $startObLevel) {
|
||||
return '';
|
||||
}
|
||||
|
||||
Response::closeOutputBuffers($startObLevel + 1, true);
|
||||
|
||||
return ob_get_clean();
|
||||
};
|
||||
}
|
||||
|
||||
private function renderException(FlattenException $exception, string $debugTemplate = 'views/exception_full.html.php'): string
|
||||
{
|
||||
$debug = \is_bool($this->debug) ? $this->debug : ($this->debug)($exception);
|
||||
$statusText = $this->escape($exception->getStatusText());
|
||||
$statusCode = $this->escape($exception->getStatusCode());
|
||||
|
||||
if (!$debug) {
|
||||
return $this->include(self::$template, [
|
||||
'statusText' => $statusText,
|
||||
'statusCode' => $statusCode,
|
||||
]);
|
||||
}
|
||||
|
||||
$exceptionMessage = $this->escape($exception->getMessage());
|
||||
|
||||
return $this->include($debugTemplate, [
|
||||
'exception' => $exception,
|
||||
'exceptionMessage' => $exceptionMessage,
|
||||
'statusText' => $statusText,
|
||||
'statusCode' => $statusCode,
|
||||
'logger' => null !== $this->logger && class_exists(DebugLoggerConfigurator::class) ? DebugLoggerConfigurator::getDebugLogger($this->logger) : null,
|
||||
'currentContent' => \is_string($this->outputBuffer) ? $this->outputBuffer : ($this->outputBuffer)(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function dumpValue(Data $value): string
|
||||
{
|
||||
$dumper = new HtmlDumper();
|
||||
$dumper->setTheme('light');
|
||||
|
||||
return $dumper->dump($value, true);
|
||||
}
|
||||
|
||||
private function formatArgs(array $args): string
|
||||
{
|
||||
$result = [];
|
||||
foreach ($args as $key => $item) {
|
||||
if ('object' === $item[0]) {
|
||||
$formattedValue = \sprintf('<em>object</em>(%s)', $this->abbrClass($item[1]));
|
||||
} elseif ('array' === $item[0]) {
|
||||
$formattedValue = \sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
|
||||
} elseif ('null' === $item[0]) {
|
||||
$formattedValue = '<em>null</em>';
|
||||
} elseif ('boolean' === $item[0]) {
|
||||
$formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
|
||||
} elseif ('resource' === $item[0]) {
|
||||
$formattedValue = '<em>resource</em>';
|
||||
} elseif (preg_match('/[^\x07-\x0D\x1B\x20-\xFF]/', $item[1])) {
|
||||
$formattedValue = '<em>binary string</em>';
|
||||
} else {
|
||||
$formattedValue = str_replace("\n", '', $this->escape(var_export($item[1], true)));
|
||||
}
|
||||
|
||||
$result[] = \is_int($key) ? $formattedValue : \sprintf("'%s' => %s", $this->escape($key), $formattedValue);
|
||||
}
|
||||
|
||||
return implode(', ', $result);
|
||||
}
|
||||
|
||||
private function formatArgsAsText(array $args): string
|
||||
{
|
||||
return strip_tags($this->formatArgs($args));
|
||||
}
|
||||
|
||||
private function escape(string $string): string
|
||||
{
|
||||
return htmlspecialchars($string, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
|
||||
}
|
||||
|
||||
private function abbrClass(string $class): string
|
||||
{
|
||||
$parts = explode('\\', $class);
|
||||
$short = array_pop($parts);
|
||||
|
||||
return \sprintf('<abbr title="%s">%s</abbr>', $class, $short);
|
||||
}
|
||||
|
||||
private function getFileRelative(string $file): ?string
|
||||
{
|
||||
$file = str_replace('\\', '/', $file);
|
||||
|
||||
if (null !== $this->projectDir && str_starts_with($file, $this->projectDir)) {
|
||||
return ltrim(substr($file, \strlen($this->projectDir)), '/');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a file path.
|
||||
*
|
||||
* @param string $file An absolute file path
|
||||
* @param int $line The line number
|
||||
* @param string $text Use this text for the link rather than the file path
|
||||
*/
|
||||
private function formatFile(string $file, int $line, ?string $text = null): string
|
||||
{
|
||||
$file = trim($file);
|
||||
|
||||
if (null === $text) {
|
||||
$text = $file;
|
||||
if (null !== $rel = $this->getFileRelative($text)) {
|
||||
$rel = explode('/', $rel, 2);
|
||||
$text = \sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->projectDir, $rel[0], '/'.($rel[1] ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < $line) {
|
||||
$text .= ' at line '.$line;
|
||||
}
|
||||
|
||||
if (!file_exists($file)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$link = $this->fileLinkFormat->format($file, $line);
|
||||
|
||||
return \sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', $this->escape($link), $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an excerpt of a code file around the given line number.
|
||||
*
|
||||
* @param string $file A file path
|
||||
* @param int $line The selected line number
|
||||
* @param int $srcContext The number of displayed lines around or -1 for the whole file
|
||||
*/
|
||||
private function fileExcerpt(string $file, int $line, int $srcContext = 3): string
|
||||
{
|
||||
if (is_file($file) && is_readable($file)) {
|
||||
// highlight_file could throw warnings
|
||||
// see https://bugs.php.net/25725
|
||||
$code = @highlight_file($file, true);
|
||||
// remove main pre/code tags
|
||||
$code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
|
||||
// split multiline span tags
|
||||
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<\\n]*+\\n)++[^<]*+)</span>#', static fn ($m) => "<span $m[1]>".str_replace("\n", "</span>\n<span $m[1]>", $m[2]).'</span>', $code);
|
||||
$content = explode("\n", $code);
|
||||
|
||||
$lines = [];
|
||||
if (0 > $srcContext) {
|
||||
$srcContext = \count($content);
|
||||
}
|
||||
|
||||
for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, \count($content)); $i <= $max; ++$i) {
|
||||
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.$this->fixCodeMarkup($content[$i - 1]).'</code></li>';
|
||||
}
|
||||
|
||||
return '<ol start="'.max($line - $srcContext, 1).'">'.implode("\n", $lines).'</ol>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
private function fixCodeMarkup(string $line): string
|
||||
{
|
||||
// </span> ending tag from previous line
|
||||
$opening = strpos($line, '<span');
|
||||
$closing = strpos($line, '</span>');
|
||||
if (false !== $closing && (false === $opening || $closing < $opening)) {
|
||||
$line = substr_replace($line, '', $closing, 7);
|
||||
}
|
||||
|
||||
// missing </span> tag at the end of line
|
||||
$opening = strrpos($line, '<span');
|
||||
$closing = strrpos($line, '</span>');
|
||||
if (false !== $opening && (false === $closing || $closing < $opening)) {
|
||||
$line .= '</span>';
|
||||
}
|
||||
|
||||
return trim($line);
|
||||
}
|
||||
|
||||
private function formatFileFromText(string $text): string
|
||||
{
|
||||
return preg_replace_callback('/in ("|")?(.+?)\1(?: +(?:on|at))? +line (\d+)/s', fn ($match) => 'in '.$this->formatFile($match[2], $match[3]), $text) ?? $text;
|
||||
}
|
||||
|
||||
private function formatLogMessage(string $message, array $context): string
|
||||
{
|
||||
if ($context && str_contains($message, '{')) {
|
||||
$replacements = [];
|
||||
foreach ($context as $key => $val) {
|
||||
if (\is_scalar($val)) {
|
||||
$replacements['{'.$key.'}'] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if ($replacements) {
|
||||
$message = strtr($message, $replacements);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->escape($message);
|
||||
}
|
||||
|
||||
private function addElementToGhost(): string
|
||||
{
|
||||
if (!isset(self::GHOST_ADDONS[date('m-d')])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<path d="'.self::GHOST_ADDONS[date('m-d')].'" fill="#fff" fill-opacity="0.6"></path>';
|
||||
}
|
||||
|
||||
private function include(string $name, array $context = []): string
|
||||
{
|
||||
extract($context, \EXTR_SKIP);
|
||||
ob_start();
|
||||
|
||||
include is_file(\dirname(__DIR__).'/Resources/'.$name) ? \dirname(__DIR__).'/Resources/'.$name : $name;
|
||||
|
||||
return trim(ob_get_clean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows overriding the default non-debug template.
|
||||
*
|
||||
* @param string $template path to the custom template file to render
|
||||
*/
|
||||
public static function setTemplate(string $template): void
|
||||
{
|
||||
self::$template = $template;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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\ErrorHandler\ErrorRenderer;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* Formats an exception using Serializer for rendering.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class SerializerErrorRenderer implements ErrorRendererInterface
|
||||
{
|
||||
private string|\Closure $format;
|
||||
private ErrorRendererInterface $fallbackErrorRenderer;
|
||||
private bool|\Closure $debug;
|
||||
|
||||
/**
|
||||
* @param string|callable(FlattenException): string $format The format as a string or a callable that should return it
|
||||
* formats not supported by Request::getMimeTypes() should be given as mime types
|
||||
* @param bool|callable $debug The debugging mode as a boolean or a callable that should return it
|
||||
*/
|
||||
public function __construct(
|
||||
private SerializerInterface $serializer,
|
||||
string|callable $format,
|
||||
?ErrorRendererInterface $fallbackErrorRenderer = null,
|
||||
bool|callable $debug = false,
|
||||
) {
|
||||
$this->format = \is_string($format) ? $format : $format(...);
|
||||
$this->fallbackErrorRenderer = $fallbackErrorRenderer ?? new HtmlErrorRenderer();
|
||||
$this->debug = \is_bool($debug) ? $debug : $debug(...);
|
||||
}
|
||||
|
||||
public function render(\Throwable $exception): FlattenException
|
||||
{
|
||||
$headers = ['Vary' => 'Accept'];
|
||||
$debug = \is_bool($this->debug) ? $this->debug : ($this->debug)($exception);
|
||||
if ($debug) {
|
||||
$headers['X-Debug-Exception'] = rawurlencode(substr($exception->getMessage(), 0, 2000));
|
||||
$headers['X-Debug-Exception-File'] = rawurlencode($exception->getFile()).':'.$exception->getLine();
|
||||
}
|
||||
|
||||
$flattenException = FlattenException::createFromThrowable($exception, null, $headers);
|
||||
|
||||
try {
|
||||
$format = \is_string($this->format) ? $this->format : ($this->format)($flattenException);
|
||||
$headers['Content-Type'] = Request::getMimeTypes($format)[0] ?? $format;
|
||||
|
||||
$flattenException->setAsString($this->serializer->serialize($flattenException, $format, [
|
||||
'exception' => $exception,
|
||||
'debug' => $debug,
|
||||
]));
|
||||
} catch (NotEncodableValueException) {
|
||||
$flattenException = $this->fallbackErrorRenderer->render($exception);
|
||||
}
|
||||
|
||||
return $flattenException->setHeaders($flattenException->getHeaders() + $headers);
|
||||
}
|
||||
|
||||
public static function getPreferredFormat(RequestStack $requestStack): \Closure
|
||||
{
|
||||
return static function () use ($requestStack) {
|
||||
if (!$request = $requestStack->getCurrentRequest()) {
|
||||
throw new NotEncodableValueException();
|
||||
}
|
||||
|
||||
return $request->getPreferredFormat();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
<?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\ErrorHandler\Exception;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Exception\RequestExceptionInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\VarDumper\Caster\Caster;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
|
||||
/**
|
||||
* FlattenException wraps a PHP Error or Exception to be able to serialize it.
|
||||
*
|
||||
* Basically, this class removes all objects from the trace.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class FlattenException
|
||||
{
|
||||
private string $message;
|
||||
private string|int $code;
|
||||
private ?self $previous = null;
|
||||
private array $trace;
|
||||
private string $traceAsString;
|
||||
private string $class;
|
||||
private int $statusCode;
|
||||
private string $statusText;
|
||||
private array $headers;
|
||||
private string $file;
|
||||
private int $line;
|
||||
private ?string $asString = null;
|
||||
private Data $dataRepresentation;
|
||||
|
||||
public static function create(\Exception $exception, ?int $statusCode = null, array $headers = []): static
|
||||
{
|
||||
return static::createFromThrowable($exception, $statusCode, $headers);
|
||||
}
|
||||
|
||||
public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = []): static
|
||||
{
|
||||
$e = new static();
|
||||
$e->setMessage($exception->getMessage());
|
||||
$e->setCode($exception->getCode());
|
||||
|
||||
if ($exception instanceof HttpExceptionInterface) {
|
||||
$statusCode = $exception->getStatusCode();
|
||||
$headers = array_merge($headers, $exception->getHeaders());
|
||||
} elseif ($exception instanceof RequestExceptionInterface) {
|
||||
$statusCode = 400;
|
||||
}
|
||||
|
||||
$statusCode ??= 500;
|
||||
|
||||
if (class_exists(Response::class) && isset(Response::$statusTexts[$statusCode])) {
|
||||
$statusText = Response::$statusTexts[$statusCode];
|
||||
} else {
|
||||
$statusText = 'Whoops, looks like something went wrong.';
|
||||
}
|
||||
|
||||
$e->setStatusText($statusText);
|
||||
$e->setStatusCode($statusCode);
|
||||
$e->setHeaders($headers);
|
||||
$e->setTraceFromThrowable($exception);
|
||||
$e->setClass(get_debug_type($exception));
|
||||
$e->setFile($exception->getFile());
|
||||
$e->setLine($exception->getLine());
|
||||
|
||||
$previous = $exception->getPrevious();
|
||||
|
||||
if ($previous instanceof \Throwable) {
|
||||
$e->setPrevious(static::createFromThrowable($previous));
|
||||
}
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public static function createWithDataRepresentation(\Throwable $throwable, ?int $statusCode = null, array $headers = [], ?VarCloner $cloner = null): static
|
||||
{
|
||||
$e = static::createFromThrowable($throwable, $statusCode, $headers);
|
||||
|
||||
static $defaultCloner;
|
||||
|
||||
if (!$cloner ??= $defaultCloner) {
|
||||
$cloner = $defaultCloner = new VarCloner();
|
||||
$cloner->addCasters([
|
||||
\Throwable::class => static function (\Throwable $e, array $a, Stub $s, bool $isNested): array {
|
||||
if (!$isNested) {
|
||||
unset($a[Caster::PREFIX_PROTECTED.'message']);
|
||||
unset($a[Caster::PREFIX_PROTECTED.'code']);
|
||||
unset($a[Caster::PREFIX_PROTECTED.'file']);
|
||||
unset($a[Caster::PREFIX_PROTECTED.'line']);
|
||||
unset($a["\0Error\0trace"], $a["\0Exception\0trace"]);
|
||||
unset($a["\0Error\0previous"], $a["\0Exception\0previous"]);
|
||||
}
|
||||
|
||||
return $a;
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
return $e->setDataRepresentation($cloner->cloneVar($throwable));
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
$exceptions = [];
|
||||
foreach (array_merge([$this], $this->getAllPrevious()) as $exception) {
|
||||
$exceptions[] = [
|
||||
'message' => $exception->getMessage(),
|
||||
'class' => $exception->getClass(),
|
||||
'trace' => $exception->getTrace(),
|
||||
'data' => $exception->getDataRepresentation(),
|
||||
];
|
||||
}
|
||||
|
||||
return $exceptions;
|
||||
}
|
||||
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatusCode(int $code): static
|
||||
{
|
||||
$this->statusCode = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeaders(array $headers): static
|
||||
{
|
||||
$this->headers = $headers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getClass(): string
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setClass(string $class): static
|
||||
{
|
||||
$this->class = str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFile(): string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setFile(string $file): static
|
||||
{
|
||||
$this->file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLine(): int
|
||||
{
|
||||
return $this->line;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setLine(int $line): static
|
||||
{
|
||||
$this->line = $line;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStatusText(): string
|
||||
{
|
||||
return $this->statusText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatusText(string $statusText): static
|
||||
{
|
||||
$this->statusText = $statusText;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setMessage(string $message): static
|
||||
{
|
||||
if (str_contains($message, "@anonymous\0")) {
|
||||
$message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)?[0-9a-fA-F]++/', static fn ($m) => class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0], $message);
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|string int most of the time (might be a string with PDOException)
|
||||
*/
|
||||
public function getCode(): int|string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode(int|string $code): static
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrevious(): ?self
|
||||
{
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrevious(?self $previous): static
|
||||
{
|
||||
$this->previous = $previous;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return self[]
|
||||
*/
|
||||
public function getAllPrevious(): array
|
||||
{
|
||||
$exceptions = [];
|
||||
$e = $this;
|
||||
while ($e = $e->getPrevious()) {
|
||||
$exceptions[] = $e;
|
||||
}
|
||||
|
||||
return $exceptions;
|
||||
}
|
||||
|
||||
public function getTrace(): array
|
||||
{
|
||||
return $this->trace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTraceFromThrowable(\Throwable $throwable): static
|
||||
{
|
||||
$this->traceAsString = $throwable->getTraceAsString();
|
||||
|
||||
return $this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setTrace(array $trace, ?string $file, ?int $line): static
|
||||
{
|
||||
$this->trace = [];
|
||||
$this->trace[] = [
|
||||
'namespace' => '',
|
||||
'short_class' => '',
|
||||
'class' => '',
|
||||
'type' => '',
|
||||
'function' => '',
|
||||
'file' => $file,
|
||||
'line' => $line,
|
||||
'args' => [],
|
||||
];
|
||||
foreach ($trace as $entry) {
|
||||
$class = '';
|
||||
$namespace = '';
|
||||
if (isset($entry['class'])) {
|
||||
$parts = explode('\\', $entry['class']);
|
||||
$class = array_pop($parts);
|
||||
$namespace = implode('\\', $parts);
|
||||
}
|
||||
|
||||
$this->trace[] = [
|
||||
'namespace' => $namespace,
|
||||
'short_class' => $class,
|
||||
'class' => $entry['class'] ?? '',
|
||||
'type' => $entry['type'] ?? '',
|
||||
'function' => $entry['function'] ?? null,
|
||||
'file' => $entry['file'] ?? null,
|
||||
'line' => $entry['line'] ?? null,
|
||||
'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : [],
|
||||
];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDataRepresentation(): ?Data
|
||||
{
|
||||
return $this->dataRepresentation ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setDataRepresentation(Data $data): static
|
||||
{
|
||||
$this->dataRepresentation = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function flattenArgs(array $args, int $level = 0, int &$count = 0): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($args as $key => $value) {
|
||||
if (++$count > 1e4) {
|
||||
return ['array', '*SKIPPED over 10000 entries*'];
|
||||
}
|
||||
if ($value instanceof \__PHP_Incomplete_Class) {
|
||||
$result[$key] = ['incomplete-object', $this->getClassNameFromIncomplete($value)];
|
||||
} elseif (\is_object($value)) {
|
||||
$result[$key] = ['object', get_debug_type($value)];
|
||||
} elseif (\is_array($value)) {
|
||||
if ($level > 10) {
|
||||
$result[$key] = ['array', '*DEEP NESTED ARRAY*'];
|
||||
} else {
|
||||
$result[$key] = ['array', $this->flattenArgs($value, $level + 1, $count)];
|
||||
}
|
||||
} elseif (null === $value) {
|
||||
$result[$key] = ['null', null];
|
||||
} elseif (\is_bool($value)) {
|
||||
$result[$key] = ['boolean', $value];
|
||||
} elseif (\is_int($value)) {
|
||||
$result[$key] = ['integer', $value];
|
||||
} elseif (\is_float($value)) {
|
||||
$result[$key] = ['float', $value];
|
||||
} elseif (\is_resource($value)) {
|
||||
$result[$key] = ['resource', get_resource_type($value)];
|
||||
} else {
|
||||
$result[$key] = ['string', (string) $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value): string
|
||||
{
|
||||
$array = new \ArrayObject($value);
|
||||
|
||||
return $array['__PHP_Incomplete_Class_Name'];
|
||||
}
|
||||
|
||||
public function getTraceAsString(): string
|
||||
{
|
||||
return $this->traceAsString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setAsString(?string $asString): static
|
||||
{
|
||||
$this->asString = $asString;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAsString(): string
|
||||
{
|
||||
if (null !== $this->asString) {
|
||||
return $this->asString;
|
||||
}
|
||||
|
||||
$message = '';
|
||||
$next = false;
|
||||
|
||||
foreach (array_reverse(array_merge([$this], $this->getAllPrevious())) as $exception) {
|
||||
if ($next) {
|
||||
$message .= 'Next ';
|
||||
} else {
|
||||
$next = true;
|
||||
}
|
||||
$message .= $exception->getClass();
|
||||
|
||||
if ('' != $exception->getMessage()) {
|
||||
$message .= ': '.$exception->getMessage();
|
||||
}
|
||||
|
||||
$message .= ' in '.$exception->getFile().':'.$exception->getLine().
|
||||
"\nStack trace:\n".$exception->getTraceAsString()."\n\n";
|
||||
}
|
||||
|
||||
return rtrim($message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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\ErrorHandler\Exception;
|
||||
|
||||
/**
|
||||
* Data Object that represents a Silenced Error.
|
||||
*
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*/
|
||||
class SilencedErrorContext implements \JsonSerializable
|
||||
{
|
||||
public int $count = 1;
|
||||
|
||||
public function __construct(
|
||||
private int $severity,
|
||||
private string $file,
|
||||
private int $line,
|
||||
private array $trace = [],
|
||||
int $count = 1,
|
||||
) {
|
||||
$this->count = $count;
|
||||
}
|
||||
|
||||
public function getSeverity(): int
|
||||
{
|
||||
return $this->severity;
|
||||
}
|
||||
|
||||
public function getFile(): string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function getLine(): int
|
||||
{
|
||||
return $this->line;
|
||||
}
|
||||
|
||||
public function getTrace(): array
|
||||
{
|
||||
return $this->trace;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'severity' => $this->severity,
|
||||
'file' => $this->file,
|
||||
'line' => $this->line,
|
||||
'trace' => $this->trace,
|
||||
'count' => $this->count,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2019-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,54 @@
|
||||
ErrorHandler Component
|
||||
======================
|
||||
|
||||
The ErrorHandler component provides tools to manage errors and ease debugging PHP code.
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
```bash
|
||||
composer require symfony/error-handler
|
||||
```
|
||||
|
||||
```php
|
||||
use Symfony\Component\ErrorHandler\Debug;
|
||||
use Symfony\Component\ErrorHandler\ErrorHandler;
|
||||
use Symfony\Component\ErrorHandler\DebugClassLoader;
|
||||
|
||||
Debug::enable();
|
||||
|
||||
// or enable only one feature
|
||||
//ErrorHandler::register();
|
||||
//DebugClassLoader::enable();
|
||||
|
||||
// If you want a custom generic template when debug is not enabled
|
||||
// HtmlErrorRenderer::setTemplate('/path/to/custom/error.html.php');
|
||||
|
||||
$data = ErrorHandler::call(static function () use ($filename, $datetimeFormat) {
|
||||
// if any code executed inside this anonymous function fails, a PHP exception
|
||||
// will be thrown, even if the code uses the '@' PHP silence operator
|
||||
$data = json_decode(file_get_contents($filename), true);
|
||||
$data['read_at'] = date($datetimeFormat);
|
||||
file_put_contents($filename, json_encode($data));
|
||||
|
||||
return $data;
|
||||
});
|
||||
```
|
||||
|
||||
Sponsor
|
||||
-------
|
||||
|
||||
This package is looking for a [backer][1].
|
||||
|
||||
Help Symfony by [sponsoring][3] its development!
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
||||
[1]: https://symfony.com/backers
|
||||
[3]: https://symfony.com/sponsor
|
||||
@@ -0,0 +1,4 @@
|
||||
body { background-color: #fff; color: #222; font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; margin: 0; }
|
||||
.container { margin: 30px; max-width: 600px; }
|
||||
h1 { color: #dc3545; font-size: 24px; }
|
||||
h2 { font-size: 18px; }
|
||||
@@ -0,0 +1,359 @@
|
||||
/* This file is based on WebProfilerBundle/Resources/views/Profiler/profiler.css.twig.
|
||||
If you make any change in this file, verify the same change is needed in the other file. */
|
||||
:root {
|
||||
--font-sans-serif: Helvetica, Arial, sans-serif;
|
||||
--page-background: #f9f9f9;
|
||||
--color-text: #222;
|
||||
/* when updating any of these colors, do the same in toolbar.css.twig */
|
||||
--color-success: #4f805d;
|
||||
--color-warning: #a46a1f;
|
||||
--color-error: #b0413e;
|
||||
--color-muted: #999;
|
||||
--tab-background: #f0f0f0;
|
||||
--tab-border-color: #e5e5e5;
|
||||
--tab-active-border-color: #d4d4d4;
|
||||
--tab-color: #444;
|
||||
--tab-active-background: #fff;
|
||||
--tab-active-color: var(--color-text);
|
||||
--tab-disabled-background: #f5f5f5;
|
||||
--tab-disabled-color: #999;
|
||||
--selected-badge-background: #e5e5e5;
|
||||
--selected-badge-color: #525252;
|
||||
--selected-badge-shadow: inset 0 0 0 1px #d4d4d4;
|
||||
--selected-badge-warning-background: #fde496;
|
||||
--selected-badge-warning-color: #785b02;
|
||||
--selected-badge-warning-shadow: inset 0 0 0 1px #e6af05;
|
||||
--selected-badge-danger-background: #FCE9ED;
|
||||
--selected-badge-danger-color: #83122A;
|
||||
--selected-badge-danger-shadow: inset 0 0 0 1px #F5B8C5;
|
||||
--metric-value-background: #fff;
|
||||
--metric-value-color: inherit;
|
||||
--metric-unit-color: #999;
|
||||
--metric-label-background: #e0e0e0;
|
||||
--metric-label-color: inherit;
|
||||
--table-border: #e0e0e0;
|
||||
--table-background: #fff;
|
||||
--table-header: #e0e0e0;
|
||||
--trace-selected-background: #F7E5A1;
|
||||
--tree-active-background: #F7E5A1;
|
||||
--exception-title-color: var(--base-2);
|
||||
--shadow: 0px 0px 1px rgba(128, 128, 128, .2);
|
||||
--border: 1px solid #e0e0e0;
|
||||
--background-error: var(--color-error);
|
||||
--highlight-comment: #969896;
|
||||
--highlight-default: #222222;
|
||||
--highlight-keyword: #a71d5d;
|
||||
--highlight-string: #183691;
|
||||
--base-0: #fff;
|
||||
--base-1: #f5f5f5;
|
||||
--base-2: #e0e0e0;
|
||||
--base-3: #ccc;
|
||||
--base-4: #666;
|
||||
--base-5: #444;
|
||||
--base-6: #222;
|
||||
}
|
||||
|
||||
.theme-dark {
|
||||
--page-background: #36393e;
|
||||
--color-text: #e0e0e0;
|
||||
--color-muted: #777;
|
||||
--color-error: #f76864;
|
||||
--tab-background: #404040;
|
||||
--tab-border-color: #737373;
|
||||
--tab-active-border-color: #171717;
|
||||
--tab-color: var(--color-text);
|
||||
--tab-active-background: #d4d4d4;
|
||||
--tab-active-color: #262626;
|
||||
--tab-disabled-background: var(--page-background);
|
||||
--tab-disabled-color: #a3a3a3;
|
||||
--selected-badge-background: #555;
|
||||
--selected-badge-color: #ddd;
|
||||
--selected-badge-shadow: none;
|
||||
--selected-badge-warning-background: #fcd55f;
|
||||
--selected-badge-warning-color: #785b02;
|
||||
--selected-badge-warning-shadow: inset 0 0 0 1px #af8503;
|
||||
--selected-badge-danger-background: #B41939;
|
||||
--selected-badge-danger-color: #FCE9ED;
|
||||
--selected-badge-danger-shadow: none;
|
||||
--metric-value-background: #555;
|
||||
--metric-value-color: inherit;
|
||||
--metric-unit-color: #999;
|
||||
--metric-label-background: #777;
|
||||
--metric-label-color: #e0e0e0;
|
||||
--trace-selected-background: #5d5227cc;
|
||||
--table-border: #444;
|
||||
--table-background: #333;
|
||||
--table-header: #555;
|
||||
--info-background: rgba(79, 148, 195, 0.5);
|
||||
--tree-active-background: var(--metric-label-background);
|
||||
--exception-title-color: var(--base-2);
|
||||
--shadow: 0px 0px 1px rgba(32, 32, 32, .2);
|
||||
--border: 1px solid #666;
|
||||
--background-error: #b0413e;
|
||||
--highlight-comment: #dedede;
|
||||
--highlight-default: var(--base-6);
|
||||
--highlight-keyword: #de8986;
|
||||
--highlight-string: #70a6fd;
|
||||
--base-0: #2e3136;
|
||||
--base-1: #444;
|
||||
--base-2: #666;
|
||||
--base-3: #666;
|
||||
--base-4: #666;
|
||||
--base-5: #e0e0e0;
|
||||
--base-6: #f5f5f5;
|
||||
--card-label-background: var(--tab-active-background);
|
||||
--card-label-color: var(--tab-active-color);
|
||||
}
|
||||
|
||||
html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{margin:0;font:inherit;color:inherit}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{padding:.35em .625em .75em;margin:0 2px;border:1px solid silver}legend{padding:0;border:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}summary{cursor: pointer}
|
||||
|
||||
html {
|
||||
/* always display the vertical scrollbar to avoid jumps when toggling contents */
|
||||
overflow-y: scroll;
|
||||
}
|
||||
body { background-color: var(--page-background); color: var(--base-6); font: 14px/1.4 Helvetica, Arial, sans-serif; padding-bottom: 45px; }
|
||||
|
||||
a { cursor: pointer; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
abbr[title] { border-bottom: none; cursor: help; text-decoration: none; }
|
||||
|
||||
code, pre { font: 13px/1.5 Consolas, Monaco, Menlo, "Ubuntu Mono", "Liberation Mono", monospace; }
|
||||
|
||||
table, tr, th, td { background: var(--base-0); border-collapse: collapse; vertical-align: top; }
|
||||
table { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 1em 0; width: 100%; }
|
||||
table th, table td { border: solid var(--base-2); border-width: 1px 0; padding: 8px 10px; }
|
||||
table th { background-color: var(--base-2); font-weight: bold; text-align: left; }
|
||||
|
||||
.m-t-5 { margin-top: 5px; }
|
||||
.hidden-xs-down { display: none; }
|
||||
.block { display: block; }
|
||||
.full-width { width: 100%; }
|
||||
.hidden { display: none; }
|
||||
.prewrap { white-space: pre-wrap; }
|
||||
.nowrap { white-space: nowrap; }
|
||||
.newline { display: block; }
|
||||
.break-long-words { word-wrap: break-word; overflow-wrap: break-word; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; hyphenate-character: ''; min-width: 0; }
|
||||
.text-small { font-size: 12px !important; }
|
||||
.text-muted { color: #999; }
|
||||
.text-bold { font-weight: bold; }
|
||||
.empty { border: 4px dashed var(--base-2); color: #999; margin: 1em 0; padding: .5em 2em; }
|
||||
|
||||
.status-success { background: rgba(94, 151, 110, 0.3); }
|
||||
.status-warning { background: rgba(240, 181, 24, 0.3); }
|
||||
.status-error { background: rgba(176, 65, 62, 0.2); }
|
||||
.status-success td, .status-warning td, .status-error td { background: transparent; }
|
||||
tr.status-error td, tr.status-warning td { border-bottom: 1px solid var(--base-2); border-top: 1px solid var(--base-2); }
|
||||
.status-warning .colored { color: #A46A1F; }
|
||||
.status-error .colored { color: var(--color-error); }
|
||||
|
||||
.sf-toggle { cursor: pointer; position: relative; }
|
||||
.sf-toggle-content { -moz-transition: display .25s ease; -webkit-transition: display .25s ease; transition: display .25s ease; }
|
||||
.sf-toggle-content.sf-toggle-hidden { display: none; }
|
||||
.sf-toggle-content.sf-toggle-visible { display: block; }
|
||||
thead.sf-toggle-content.sf-toggle-visible, tbody.sf-toggle-content.sf-toggle-visible { display: table-row-group; }
|
||||
.sf-toggle-off .icon-close, .sf-toggle-on .icon-open { display: none; }
|
||||
.sf-toggle-off .icon-open, .sf-toggle-on .icon-close { display: block; }
|
||||
|
||||
.tab-navigation {
|
||||
background-color: var(--tab-background);
|
||||
border-radius: 6px;
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color), 0 0 0 5px var(--page-background);
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 0 15px;
|
||||
padding: 0;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
.sf-tabs-sm .tab-navigation {
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color), 0 0 0 4px var(--page-background);
|
||||
margin: 0 0 10px;
|
||||
}
|
||||
.tab-navigation .tab-control {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
transition: box-shadow .05s ease-in, background-color .05s ease-in;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
margin: 0;
|
||||
padding: 4px 14px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
z-index: 1;
|
||||
}
|
||||
.sf-tabs-sm .tab-navigation .tab-control {
|
||||
font-size: 13px;
|
||||
padding: 2.5px 10px;
|
||||
}
|
||||
.tab-navigation .tab-control:before {
|
||||
background: var(--tab-border-color);
|
||||
bottom: 15%;
|
||||
content: "";
|
||||
left: 0;
|
||||
position: absolute;
|
||||
top: 15%;
|
||||
width: 1px;
|
||||
}
|
||||
.tab-navigation .tab-control:first-child:before,
|
||||
.tab-navigation .tab-control.active + .tab-control:before,
|
||||
.tab-navigation .tab-control.active:before {
|
||||
width: 0;
|
||||
}
|
||||
.tab-navigation .tab-control .badge {
|
||||
background: var(--selected-badge-background);
|
||||
box-shadow: var(--selected-badge-shadow);
|
||||
color: var(--selected-badge-color);
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
margin-left: 8px;
|
||||
min-width: 10px;
|
||||
padding: 2px 6px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.tab-navigation .tab-control.disabled {
|
||||
color: var(--tab-disabled-color);
|
||||
}
|
||||
.tab-navigation .tab-control.active {
|
||||
background-color: var(--tab-active-background);
|
||||
border-radius: 6px;
|
||||
box-shadow: inset 0 0 0 1.5px var(--tab-active-border-color);
|
||||
color: var(--tab-active-color);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
.theme-dark .tab-navigation li.active {
|
||||
box-shadow: inset 0 0 0 1px var(--tab-border-color);
|
||||
}
|
||||
.tab-content > *:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
.tab-navigation .tab-control .badge.status-warning {
|
||||
background: var(--selected-badge-warning-background);
|
||||
box-shadow: var(--selected-badge-warning-shadow);
|
||||
color: var(--selected-badge-warning-color);
|
||||
}
|
||||
.tab-navigation .tab-control .badge.status-error {
|
||||
background: var(--selected-badge-danger-background);
|
||||
box-shadow: var(--selected-badge-danger-shadow);
|
||||
color: var(--selected-badge-danger-color);
|
||||
}
|
||||
|
||||
.sf-tabs .tab:not(:first-child) { display: none; }
|
||||
|
||||
[data-filters] { position: relative; }
|
||||
[data-filtered] { cursor: pointer; }
|
||||
[data-filtered]:after { content: '\00a0\25BE'; }
|
||||
[data-filtered]:hover .filter-list li { display: inline-flex; }
|
||||
[class*="filter-hidden-"] { display: none; }
|
||||
.filter-list { position: absolute; border: var(--border); box-shadow: var(--shadow); margin: 0; padding: 0; display: flex; flex-direction: column; }
|
||||
.filter-list :after { content: ''; }
|
||||
.filter-list li {
|
||||
background: var(--tab-disabled-background);
|
||||
border-bottom: var(--border);
|
||||
color: var(--tab-disabled-color);
|
||||
display: none;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 5px 10px;
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
}
|
||||
.filter-list li.active {
|
||||
background: var(--tab-background);
|
||||
color: var(--tab-color);
|
||||
}
|
||||
.filter-list li.last-active {
|
||||
background: var(--tab-active-background);
|
||||
color: var(--tab-active-color);
|
||||
}
|
||||
|
||||
.filter-list-level li { cursor: s-resize; }
|
||||
.filter-list-level li.active { cursor: n-resize; }
|
||||
.filter-list-level li.last-active { cursor: default; }
|
||||
.filter-list-level li.last-active:before { content: '\2714\00a0'; }
|
||||
.filter-list-choice li:before { content: '\2714\00a0'; color: transparent; }
|
||||
.filter-list-choice li.active:before { color: unset; }
|
||||
|
||||
.container { max-width: 1024px; margin: 0 auto; padding: 0 15px; }
|
||||
.container::after { content: ""; display: table; clear: both; }
|
||||
|
||||
header { background-color: #222; color: rgba(255, 255, 255, 0.75); font-size: 13px; height: 33px; line-height: 33px; padding: 0; }
|
||||
header .container { display: flex; justify-content: space-between; }
|
||||
.logo { flex: 1; font-size: 13px; font-weight: normal; margin: 0; padding: 0; }
|
||||
.logo svg { height: 18px; width: 18px; opacity: .8; vertical-align: -5px; }
|
||||
|
||||
.help-link { margin-left: 15px; }
|
||||
.help-link a { color: inherit; }
|
||||
.help-link .icon svg { height: 15px; width: 15px; opacity: .7; vertical-align: -2px; }
|
||||
.help-link a:hover { color: #EEE; text-decoration: none; }
|
||||
.help-link a:hover svg { opacity: .9; }
|
||||
|
||||
.exception-summary { background: var(--background-error); border-bottom: 2px solid rgba(0, 0, 0, 0.1); border-top: 1px solid rgba(0, 0, 0, .3); flex: 0 0 auto; margin-bottom: 15px; }
|
||||
.exception-metadata { background: rgba(0, 0, 0, 0.1); padding: 7px 0; }
|
||||
.exception-metadata .container { display: flex; flex-direction: row; justify-content: space-between; }
|
||||
.exception-metadata h2, .exception-metadata h2 > a { color: rgba(255, 255, 255, 0.8); font-size: 13px; font-weight: 400; margin: 0; }
|
||||
.exception-http small { font-size: 13px; opacity: .7; }
|
||||
.exception-hierarchy { flex: 1; }
|
||||
.exception-hierarchy .icon { margin: 0 3px; opacity: .7; }
|
||||
.exception-hierarchy .icon svg { height: 13px; width: 13px; vertical-align: -2px; }
|
||||
|
||||
.exception-without-message .exception-message-wrapper { display: none; }
|
||||
.exception-message-wrapper .container { display: flex; align-items: flex-start; min-height: 70px; padding: 10px 15px 8px; }
|
||||
.exception-message { flex-grow: 1; }
|
||||
.exception-message, .exception-message a { color: #FFF; font-size: 21px; font-weight: 400; margin: 0; }
|
||||
.exception-message.long { font-size: 18px; }
|
||||
.exception-message a { border-bottom: 1px solid rgba(255, 255, 255, 0.5); font-size: inherit; text-decoration: none; }
|
||||
.exception-message a:hover { border-bottom-color: #ffffff; }
|
||||
|
||||
.exception-properties-wrapper { margin: .8em 0; }
|
||||
.exception-properties { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); }
|
||||
.exception-properties pre { margin: 0; padding: 0.2em 0; }
|
||||
|
||||
.exception-illustration { flex-basis: 111px; flex-shrink: 0; height: 66px; margin-left: 15px; opacity: .7; }
|
||||
|
||||
.trace + .trace { margin-top: 30px; }
|
||||
.trace-head { background-color: var(--base-2); padding: 10px; position: relative; }
|
||||
.trace-head .trace-class { color: var(--base-6); font-size: 18px; font-weight: bold; line-height: 1.3; margin: 0; position: relative; }
|
||||
.trace-head .trace-namespace { color: #999; display: block; font-size: 13px; }
|
||||
.trace-head .icon { position: absolute; right: 0; top: 0; }
|
||||
.trace-head .icon svg { fill: var(--base-5); height: 24px; width: 24px; }
|
||||
|
||||
.trace-details { background: var(--base-0); border: var(--border); box-shadow: 0px 0px 1px rgba(128, 128, 128, .2); margin: 0 0 1em; table-layout: fixed; }
|
||||
|
||||
.trace-message { font-size: 14px; font-weight: normal; margin: .5em 0 0; }
|
||||
|
||||
.trace-line { position: relative; padding-top: 8px; padding-bottom: 8px; }
|
||||
.trace-line + .trace-line { border-top: var(--border); }
|
||||
.trace-line:hover { background: var(--base-1); }
|
||||
.trace-line a { color: var(--base-6); }
|
||||
.trace-line .icon { opacity: .4; position: absolute; left: 10px; }
|
||||
.trace-line .icon svg { fill: var(--base-5); height: 16px; width: 16px; }
|
||||
.trace-line .icon.icon-copy { left: auto; top: auto; padding-left: 5px; display: none }
|
||||
.trace-line:hover .icon.icon-copy:not(.hidden) { display: inline-block }
|
||||
.trace-line-header { padding-left: 36px; padding-right: 10px; }
|
||||
|
||||
.trace-file-path, .trace-file-path a { color: var(--base-6); font-size: 13px; }
|
||||
.trace-class { color: var(--color-error); }
|
||||
.trace-type { padding: 0 2px; }
|
||||
.trace-method { color: var(--color-error); font-weight: bold; }
|
||||
.trace-arguments { color: #777; font-weight: normal; padding-left: 2px; }
|
||||
|
||||
.trace-code { background: var(--base-0); font-size: 12px; margin: 10px 10px 2px 10px; padding: 10px; overflow-x: auto; white-space: nowrap; }
|
||||
.trace-code ol { margin: 0; float: left; }
|
||||
.trace-code li { color: #969896; margin: 0; padding-left: 10px; float: left; width: 100%; }
|
||||
.trace-code li + li { margin-top: 5px; }
|
||||
.trace-code li.selected { background: var(--trace-selected-background); margin-top: 2px; }
|
||||
.trace-code li code { color: var(--base-6); white-space: pre; }
|
||||
|
||||
.trace-as-text .stacktrace { line-height: 1.8; margin: 0 0 15px; white-space: pre-wrap; }
|
||||
|
||||
@media (min-width: 575px) {
|
||||
.hidden-xs-down { display: initial; }
|
||||
.help-link { margin-left: 30px; }
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
.sf-reset .traces {
|
||||
padding-bottom: 14px;
|
||||
}
|
||||
.sf-reset .traces li {
|
||||
font-size: 12px;
|
||||
color: #868686;
|
||||
padding: 5px 4px;
|
||||
list-style-type: decimal;
|
||||
margin-left: 20px;
|
||||
}
|
||||
.sf-reset #logs .traces li.error {
|
||||
font-style: normal;
|
||||
color: #AA3333;
|
||||
background: #f9ecec;
|
||||
}
|
||||
.sf-reset #logs .traces li.warning {
|
||||
font-style: normal;
|
||||
background: #ffcc00;
|
||||
}
|
||||
/* fix for Opera not liking empty <li> */
|
||||
.sf-reset .traces li:after {
|
||||
content: "\00A0";
|
||||
}
|
||||
.sf-reset .trace {
|
||||
border: 1px solid #D3D3D3;
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
margin: 10px 0 20px;
|
||||
}
|
||||
.sf-reset .block-exception {
|
||||
-moz-border-radius: 16px;
|
||||
-webkit-border-radius: 16px;
|
||||
border-radius: 16px;
|
||||
margin-bottom: 20px;
|
||||
background-color: #f6f6f6;
|
||||
border: 1px solid #dfdfdf;
|
||||
padding: 30px 28px;
|
||||
word-wrap: break-word;
|
||||
overflow: hidden;
|
||||
}
|
||||
.sf-reset .block-exception div {
|
||||
color: #313131;
|
||||
font-size: 10px;
|
||||
}
|
||||
.sf-reset .block-exception-detected .illustration-exception,
|
||||
.sf-reset .block-exception-detected .text-exception {
|
||||
float: left;
|
||||
}
|
||||
.sf-reset .block-exception-detected .illustration-exception {
|
||||
width: 152px;
|
||||
}
|
||||
.sf-reset .block-exception-detected .text-exception {
|
||||
width: 670px;
|
||||
padding: 30px 44px 24px 46px;
|
||||
position: relative;
|
||||
}
|
||||
.sf-reset .text-exception .open-quote,
|
||||
.sf-reset .text-exception .close-quote {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
position: absolute;
|
||||
color: #C9C9C9;
|
||||
font-size: 8em;
|
||||
}
|
||||
.sf-reset .open-quote {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.sf-reset .close-quote {
|
||||
bottom: -0.5em;
|
||||
right: 50px;
|
||||
}
|
||||
.sf-reset .block-exception p {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.sf-reset .block-exception p a,
|
||||
.sf-reset .block-exception p a:hover {
|
||||
color: #565656;
|
||||
}
|
||||
.sf-reset .logs h2 {
|
||||
float: left;
|
||||
width: 654px;
|
||||
}
|
||||
.sf-reset .error-count, .sf-reset .support {
|
||||
float: right;
|
||||
width: 170px;
|
||||
text-align: right;
|
||||
}
|
||||
.sf-reset .error-count span {
|
||||
display: inline-block;
|
||||
background-color: #aacd4e;
|
||||
-moz-border-radius: 6px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
padding: 4px;
|
||||
color: white;
|
||||
margin-right: 2px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sf-reset .support a {
|
||||
display: inline-block;
|
||||
-moz-border-radius: 6px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
padding: 4px;
|
||||
color: #000000;
|
||||
margin-right: 2px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sf-reset .toggle {
|
||||
vertical-align: middle;
|
||||
}
|
||||
.sf-reset .linked ul,
|
||||
.sf-reset .linked li {
|
||||
display: inline;
|
||||
}
|
||||
.sf-reset #output-content {
|
||||
color: #000;
|
||||
font-size: 12px;
|
||||
}
|
||||
.sf-reset #traces-text pre {
|
||||
white-space: pre;
|
||||
font-size: 12px;
|
||||
font-family: monospace;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="#FFF" d="M1363 877l-742 742q-19 19-45 19t-45-19l-166-166q-19-19-19-45t19-45l531-531-531-531q-19-19-19-45t19-45L531 45q19-19 45-19t45 19l742 742q19 19 19 45t-19 45z"/></svg>
|
||||
|
After Width: | Height: | Size: 276 B |
@@ -0,0 +1 @@
|
||||
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAgCAYAAAABtRhCAAADVUlEQVRIx82XX0jTURTHLYPyqZdefQx66CEo80+aYpoIkqzUikz6Z5klQoWUWYRIJYEUGpQ+lIr9U5dOTLdCtkmWZis3rbnC5fw/neYW002307mX/cZvP3/7o1PwwOdh95x7vnf39zvnd29AgBer2xO6DclAXiMqZAqxIiNIN/IYSUS2BPhjmGATchUxI+ADWiRhpWK7HKuHFVBFdmU5YvnI4grFGCaReF/EBH4KsZlGgj2JBTuCYBWRIYF8YoEOJ6wBt/gEs7mBbyOjQXruPLSdOgPCiEiPSUUHDoL8Ug5IUo9B/d5wrt+G7OAKNrODPuVdB6vRCIzN6SdBlpW9RIgk/1FeAXabzRlrUPVCS/JhbmwudztnGeeH9AyXBIwtmM3wLinZJZHifjHw2V+NBoRh+9ixQrbgbnaSIcl7cGea6hoXQbNe7za241oeO5Z0p42M4BV2EqP2D50wo+6HzvwC6C4sApNOR8cmOrtcnhtj2kYRyC9eBvXzKrBZrXSs72kFd1t3MoKVbMekQkEnSNKOO8fac3LpmK6l1TlGtsxmsdKFsecPYgwxst0cwROMYDXboSotg0WLBRqjY51jLYcENElXwW2XJKPydvoI2GN9T8rBtrAArYIUruBJXkFheCQYlCpQP6uk5dAQFQNaUROMSGVQFxLmkoQsxDJrhLbTZ+nvVsERME9MgPJRKV/58AsyomTSzE813WLFvWK++qI0xSfQl8k8Pg46sYRuv5t6dS+4RqxDwaa4BGjYH+NTQvKScIp9+YL/hoZh3jDtLRHtt2C3g6bmhX+CpsFBWg7ilDSPgj0lD2ncr5ev/BP8VvyAJhqVyZeUhPOrEhEFxgEtjft846Z/guQTNT89Q5P9flMLoth4F7808wKtWWKzAwNQHxrh/1vaid2F+XpYTSbQf1XA2McOmOpROnvpvMEA4tSjq1cW0sws2gCYxswY6TKkvzYnJq1NHZLnRU4BX+4U0uburvusu8Kv8iHY7qefkM4IFngJHEOUXmLEPgiGsI8YnlZILit3vSSLRTQe/MPIZva5pshNIEmyFQlCvruJKXPkCEfmePzkphXHdzZNQdoRI9KPlBAxlj/I8U97ERPS5bjGbWDFbEdqHVe5caTBeZZx2H/IMvzeN15yoQAAAABJRU5ErkJggg==
|
||||
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="#FFF" d="M1703 478q40 57 18 129l-275 906q-19 64-76.5 107.5T1247 1664H324q-77 0-148.5-53.5T76 1479q-24-67-2-127 0-4 3-27t4-37q1-8-3-21.5t-3-19.5q2-11 8-21t16.5-23.5T116 1179q23-38 45-91.5t30-91.5q3-10 .5-30t-.5-28q3-11 17-28t17-23q21-36 42-92t25-90q1-9-2.5-32t.5-28q4-13 22-30.5t22-22.5q19-26 42.5-84.5T404 411q1-8-3-25.5t-2-26.5q2-8 9-18t18-23 17-21q8-12 16.5-30.5t15-35 16-36 19.5-32 26.5-23.5 36-11.5T620 134l-1 3q38-9 51-9h761q74 0 114 56t18 130l-274 906q-36 119-71.5 153.5T1089 1408H220q-27 0-38 15-11 16-1 43 24 70 144 70h923q29 0 56-15.5t35-41.5l300-987q7-22 5-57 38 15 59 43zm-1064 2q-4 13 2 22.5t20 9.5h608q13 0 25.5-9.5T1311 480l21-64q4-13-2-22.5t-20-9.5H702q-13 0-25.5 9.5T660 416zm-83 256q-4 13 2 22.5t20 9.5h608q13 0 25.5-9.5T1228 736l21-64q4-13-2-22.5t-20-9.5H619q-13 0-25.5 9.5T577 672z"/></svg>
|
||||
|
After Width: | Height: | Size: 913 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
|
||||
|
After Width: | Height: | Size: 265 B |
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1344 800v64q0 14-9 23t-23 9H480q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448V416q0-66-47-113t-113-47H480q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5T1312 1536H480q-119 0-203.5-84.5T192 1248V416q0-119 84.5-203.5T480 128h832q119 0 203.5 84.5T1600 416z"/></svg>
|
||||
|
After Width: | Height: | Size: 432 B |
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1408 960V832q0-26-19-45t-45-19H448q-26 0-45 19t-19 45v128q0 26 19 45t45 19h896q26 0 45-19t19-45zm256-544v960q0 119-84.5 203.5T1376 1664H416q-119 0-203.5-84.5T128 1376V416q0-119 84.5-203.5T416 128h960q119 0 203.5 84.5T1664 416z"/></svg>
|
||||
|
After Width: | Height: | Size: 337 B |
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1344 800v64q0 14-9 23t-23 9H960v352q0 14-9 23t-23 9h-64q-14 0-23-9t-9-23V896H480q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h352V416q0-14 9-23t23-9h64q14 0 23 9t9 23v352h352q14 0 23 9t9 23zm128 448V416q0-66-47-113t-113-47H480q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5T1312 1536H480q-119 0-203.5-84.5T192 1248V416q0-119 84.5-203.5T480 128h832q119 0 203.5 84.5T1600 416z"/></svg>
|
||||
|
After Width: | Height: | Size: 526 B |
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1408 960V832q0-26-19-45t-45-19h-320V448q0-26-19-45t-45-19H832q-26 0-45 19t-19 45v320H448q-26 0-45 19t-19 45v128q0 26 19 45t45 19h320v320q0 26 19 45t45 19h128q26 0 45-19t19-45v-320h320q26 0 45-19t19-45zm256-544v960q0 119-84.5 203.5T1376 1664H416q-119 0-203.5-84.5T128 1376V416q0-119 84.5-203.5T416 128h960q119 0 203.5 84.5T1664 416z"/></svg>
|
||||
|
After Width: | Height: | Size: 442 B |
@@ -0,0 +1 @@
|
||||
<svg width="1792" height="1792" viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path fill="#FFF" d="M896 0q182 0 348 71t286 191 191 286 71 348-71 348-191 286-286 191-348 71-348-71-286-191-191-286T0 896t71-348 191-286T548 71 896 0zm0 128q-190 0-361 90l194 194q82-28 167-28t167 28l194-194q-171-90-361-90zM218 1257l194-194q-28-82-28-167t28-167L218 535q-90 171-90 361t90 361zm678 407q190 0 361-90l-194-194q-82 28-167 28t-167-28l-194 194q171 90 361 90zm0-384q159 0 271.5-112.5T1280 896t-112.5-271.5T896 512 624.5 624.5 512 896t112.5 271.5T896 1280zm484-217l194 194q90-171 90-361t-90-361l-194 194q28 82 28 167t-28 167z"/></svg>
|
||||
|
After Width: | Height: | Size: 634 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 136 81" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.4"><path d="M92.4 20.4a23.2 23.2 0 0 1 9 1.9 23.7 23.7 0 0 1 5.2 3 24.3 24.3 0 0 1 3.4 3.4 24.8 24.8 0 0 1 5 9.4c.5 1.7.8 3.4 1 5.2v14.5h.4l.5.2a7.4 7.4 0 0 0 2.5.2l.2-.2.6-.8.8-1.3-.2-.1a5.5 5.5 0 0 1-.8-.3 5.6 5.6 0 0 1-2.3-1.8 5.7 5.7 0 0 1-.9-1.6 6.5 6.5 0 0 1-.2-2.8 7.3 7.3 0 0 1 .5-2l.3-.3.8-.9.3-.3c.2-.2.5-.3.8-.3H120.7c.2 0 .3-.1.4 0h.4l.2.1.3.2.2-.4.3-.4.1-.1 1.2-1 .3-.2.4-.1.4-.1h.3l1.5.1.4.1.8.5.1.2 1 1.1v.2H129.4l.4-.2 1.4-.5h1.1c.3 0 .7.2 1 .4.2 0 .3.2.5.3l.2.2.5.3.4.6.1.3.4 1.4.1.4v.6a7.8 7.8 0 0 1-.1.6 9.9 9.9 0 0 1-.8 2.4 7.8 7.8 0 0 1-3 3.3 6.4 6.4 0 0 1-1 .5 6.1 6.1 0 0 1-.6.2l-.7.1h-.1a23.4 23.4 0 0 1-.2 1.7 14.3 14.3 0 0 1-.6 2.1l-.8 2a9.2 9.2 0 0 1-.4.6l-.7 1a9.1 9.1 0 0 1-2.3 2.2c-.9.5-2 .6-3 .7l-1.4.1h-.5l-.4.1a15.8 15.8 0 0 1-2.8-.1v4.2a9.7 9.7 0 0 1-.7 3.5 9.6 9.6 0 0 1-1.7 2.8 9.3 9.3 0 0 1-3 2.3 9 9 0 0 1-5.4.7 9 9 0 0 1-3-1 9.4 9.4 0 0 1-2.7-2.5 10 10 0 0 1-1 1.2 9.3 9.3 0 0 1-2 1.3 9 9 0 0 1-2.4 1 9 9 0 0 1-6.5-1.1A9.4 9.4 0 0 1 85 77V77a10.9 10.9 0 0 1-.6.6 9.3 9.3 0 0 1-2.7 2 9 9 0 0 1-6 .8 9 9 0 0 1-2.4-1 9.3 9.3 0 0 1-2.3-1.7 9.6 9.6 0 0 1-1.8-2.8 9.7 9.7 0 0 1-.8-3.7v-4a18.5 18.5 0 0 1-2.9.2l-1.2-.1c-1.9-.3-3.7-1-5.1-2.2a8.2 8.2 0 0 1-1.1-1 10.2 10.2 0 0 1-.9-1.2 15.3 15.3 0 0 1-.7-1.3 20.8 20.8 0 0 1-1.9-6.2v-.2a6.5 6.5 0 0 1-1-.3 6.1 6.1 0 0 1-.6-.3 6.6 6.6 0 0 1-.9-.6 8.2 8.2 0 0 1-2.7-3.7 10 10 0 0 1-.3-1 10.3 10.3 0 0 1-.3-1.9V47v-.4l.1-.4.6-1.4.1-.2a2 2 0 0 1 .8-.8l.3-.2.3-.2a3.2 3.2 0 0 1 1.8-.5h.4l.3.2 1.4.6.2.2.4.3.3.4.7-.7.2-.2.4-.2.6-.2h2.1l.4.2.4.2.3.2.8 1 .2-.1h.1v-.1H63l1.1.1h.3l.8.5.3.4.7 1 .2.3.1.5a11 11 0 0 1 .2 1.5c0 .8 0 1.6-.3 2.3a6 6 0 0 1-.5 1.2 5.5 5.5 0 0 1-3.3 2.5 12.3 12.3 0 0 0 1.4 3h.1l.2.1 1 .2h1.5l.5-.2H67.8l.5-.2h.1V44v-.4a26.7 26.7 0 0 1 .3-2.3 24.7 24.7 0 0 1 5.7-12.5 24.2 24.2 0 0 1 3.5-3.3 23.7 23.7 0 0 1 4.9-3 23.2 23.2 0 0 1 5.6-1.7 23.7 23.7 0 0 1 4-.3zm-.3 2a21.2 21.2 0 0 0-8 1.7 21.6 21.6 0 0 0-4.8 2.7 22.2 22.2 0 0 0-3.2 3 22.7 22.7 0 0 0-5 9.2 23.4 23.4 0 0 0-.7 4.9v15.7l-.5.1a34.3 34.3 0 0 1-1.5.3h-.2l-.4.1h-.4l-.9.2a10 10 0 0 1-1.9 0c-.5 0-1-.2-1.5-.4a1.8 1.8 0 0 1-.3-.2 2 2 0 0 1-.3-.3 5.2 5.2 0 0 1-.1-.2 9 9 0 0 1-.6-.9 13.8 13.8 0 0 1-1-2 14.3 14.3 0 0 1-.6-2 14 14 0 0 1-.1-.8v-.2h.3a12.8 12.8 0 0 0 1.4-.2 4.4 4.4 0 0 0 .3 0 3.6 3.6 0 0 0 1.1-.7 3.4 3.4 0 0 0 1.2-1.7l.2-1.2a5.1 5.1 0 0 0 0-.8 7.2 7.2 0 0 0-.1-.8l-.7-1-1.2-.2-1 .7-.1 1.3a5 5 0 0 1 .1.4v.6a1 1 0 0 1 0 .3c-.1.3-.4.4-.7.5l-1.2.4v-.7A9.9 9.9 0 0 1 60 49l.3-.6v-.2l.1-.1v-1.6l-1-1.2h-1.5l-1 1.1v.4a5.3 5.3 0 0 0-.2.6 5.5 5.5 0 0 0 0 .5c0 .7 0 1.4.3 2 0 .4.2.8.4 1.2L57 51a9.5 9.5 0 0 1-1.1-.5h-.2a2 2 0 0 1-.4-.3c-.4-.4-.5-1-.6-1.6a5.6 5.6 0 0 1 0-.5v-.5-.5l-.6-1.5-1.4-.6-.9.3s-.2 0-.3.2a2 2 0 0 1-.1 0l-.6 1.4v.7a8.5 8.5 0 0 0 .5 2c.4 1.1 1 2.1 2 2.8a4.7 4.7 0 0 0 2.1.9h1a22.8 22.8 0 0 0 .1 1 18.1 18.1 0 0 0 .8 3.8 18.2 18.2 0 0 0 1.6 3.7l1 1.3c1 1 2.3 1.6 3.7 2a11.7 11.7 0 0 0 4.8 0h.4l.5-.2.5-.1.6-.2v6.6a8 8 0 0 0 .1 1.3 7.5 7.5 0 0 0 2.4 4.3 7.2 7.2 0 0 0 2.3 1.3 7 7 0 0 0 7-1.1 7.5 7.5 0 0 0 2-2.6A7.7 7.7 0 0 0 85 72V71a8.2 8.2 0 0 0 .2 1.3c0 .7.3 1.4.6 2a7.5 7.5 0 0 0 1.7 2.3 7.3 7.3 0 0 0 2.2 1.4 7.1 7.1 0 0 0 4.6.2 7.2 7.2 0 0 0 2.4-1.2 7.5 7.5 0 0 0 2.1-2.7 7.8 7.8 0 0 0 .7-2.4V71a9.3 9.3 0 0 0 .1.6 7.6 7.6 0 0 0 .6 2.5 7.5 7.5 0 0 0 2.4 3 7.1 7.1 0 0 0 7 .8 7.3 7.3 0 0 0 2.3-1.5 7.5 7.5 0 0 0 1.6-2.3 7.6 7.6 0 0 0 .5-2l.1-1.1v-6.7l.4.1a12.2 12.2 0 0 0 2 .5 11.1 11.1 0 0 0 2.5 0h.8l1.2-.1a9.5 9.5 0 0 0 1.4-.2l.9-.3a3.5 3.5 0 0 0 .6-.4l1.2-1.4a12.2 12.2 0 0 0 .8-1.2c0-.3.2-.5.3-.7a15.9 15.9 0 0 0 .7-2l.3-1.6v-1.3l.2-.9V54.6a15.5 15.5 0 0 0 1.8 0 4.5 4.5 0 0 0 1.4-.5 5.7 5.7 0 0 0 2.5-3.2 7.6 7.6 0 0 0 .4-1.5v-.3l-.4-1.4a5.2 5.2 0 0 1-.2-.1l-.4-.4a3.8 3.8 0 0 0-.2 0 1.4 1.4 0 0 0-.5-.2l-1.4.4-.7 1.3v.7a5.7 5.7 0 0 1-.1.8l-.7 1.4a1.9 1.9 0 0 1-.5.3h-.3a9.6 9.6 0 0 1-.8.3 8.8 8.8 0 0 1-.6 0l.2-.4.2-.5.2-.3v-.4l.1-.2V50l.1-1 .1-.6v-.6a4.8 4.8 0 0 0 0-.8v-.2l-1-1.1-1.5-.2-1.1 1-.2 1.4v.1l.2.4.2.3v.4l.1 1.1v.3l.1.5v.8a9.6 9.6 0 0 1-.8-.3l-.2-.1h-.3l-.8-.1h-.2a1.6 1.6 0 0 1-.2-.2.9.9 0 0 1-.2-.2 1 1 0 0 1-.1-.5l.2-.9v-1.2l-.9-.8h-1.2l-.8.9v.3a4.8 4.8 0 0 0-.3 2l.3.9a3.5 3.5 0 0 0 1.2 1.6l1 .5.8.2 1.4.1h.4l.2.1a12.1 12.1 0 0 1-1 2.6 13.2 13.2 0 0 1-.8 1.5 9.5 9.5 0 0 1-1 1.2l-.2.3a1.7 1.7 0 0 1-.4.3 2.4 2.4 0 0 1-.7.2h-2.5a7.8 7.8 0 0 1-.6-.2l-.7-.2h-.2a14.8 14.8 0 0 1-.6-.2 23.4 23.4 0 0 1-.4-.1l-.4-.1-.3-.1V43.9a34.6 34.6 0 0 0 0-.6 23.6 23.6 0 0 0-.4-3 22.7 22.7 0 0 0-1.5-4.7 22.6 22.6 0 0 0-4.6-6.7 21.9 21.9 0 0 0-6.9-4.7 21.2 21.2 0 0 0-8.1-1.8H92zm9.1 33.7l.3.1a1 1 0 0 1 .6.8v.4a8.4 8.4 0 0 1 0 .5 8.8 8.8 0 0 1-1.6 4.2l-1 1.3A10 10 0 0 1 95 66c-1.3.3-2.7.4-4 .3a10.4 10.4 0 0 1-2.7-.8 10 10 0 0 1-3.6-2.5 9.3 9.3 0 0 1-.8-1 9 9 0 0 1-.7-1.2 8.6 8.6 0 0 1-.8-3.4V57a1 1 0 0 1 .3-.6 1 1 0 0 1 1.3-.2 1 1 0 0 1 .4.8v.4a6.5 6.5 0 0 0 .5 2.2 7 7 0 0 0 2.1 2.8l1 .6c2.6 1.6 6 1.6 8.5 0a8 8 0 0 0 1.1-.6 7.6 7.6 0 0 0 1.2-1.2 7 7 0 0
Line truncated
|
||||
|
After Width: | Height: | Size: 8.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#FFF" d="M12 .9C5.8.9.9 5.8.9 12a11 11 0 1 0 22.2 0A11 11 0 0 0 12 .9zm6.5 6c-.6 0-.9-.3-.9-.8 0-.2 0-.4.2-.6l.2-.4c0-.3-.5-.4-.6-.4-1.8.1-2.3 2.5-2.7 4.4l-.2 1c1 .2 1.8 0 2.2-.3.6-.4-.2-.7-.1-1.2.1-.3.5-.5.7-.6.5 0 .7.5.7.9 0 .7-1 1.8-3 1.8l-.6-.1-.6 2.4c-.4 1.6-.8 3.8-2.4 5.7-1.4 1.7-2.9 1.9-3.5 1.9-1.2 0-1.9-.6-2-1.5 0-.8.7-1.3 1.2-1.3.6 0 1.1.5 1.1 1s-.2.6-.4.6c-.1.1-.3.2-.3.4 0 .1.1.3.4.3.5 0 .8-.3 1.1-.5 1.2-.9 1.6-2.7 2.2-5.7l.1-.7.7-3.2c-.8-.6-1.3-1.4-2.4-1.7-.6-.1-1.1.1-1.5.5-.4.5-.2 1.1.2 1.5l.7.6c.7.8 1.2 1.6 1 2.5-.3 1.5-2 2.6-4 1.9-1.8-.6-2-1.8-1.8-2.5.2-.6.6-.7 1.1-.6.5.2.6.7.6 1.2l-.1.3c-.2.1-.3.3-.3.4-.1.4.4.6.7.7.7.3 1.6-.2 1.8-.8a1 1 0 0 0-.4-1.1l-.7-.8c-.4-.4-1.1-1.4-.7-2.6.1-.5.4-.9.7-1.3a4 4 0 0 1 2.8-.6c1.2.4 1.8 1.1 2.6 1.8.5-1.2 1-2.4 1.8-3.5.9-.9 1.9-1.6 3.1-1.7 1.3.2 2.2.7 2.2 1.6 0 .4-.2 1.1-.9 1.1z"/></svg>
|
||||
|
After Width: | Height: | Size: 942 B |
@@ -0,0 +1,286 @@
|
||||
/* This file is based on WebProfilerBundle/Resources/views/Profiler/base_js.html.twig.
|
||||
If you make any change in this file, verify the same change is needed in the other file. */
|
||||
/*<![CDATA[*/
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
if ('classList' in document.documentElement) {
|
||||
var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
|
||||
var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
|
||||
var addClass = function(el, cssClass) { el.classList.add(cssClass); };
|
||||
var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
|
||||
} else {
|
||||
var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\b' + cssClass + '\\b')); };
|
||||
var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\b' + cssClass + '\\b'), ' '); };
|
||||
var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += " " + cssClass; } };
|
||||
var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
|
||||
}
|
||||
|
||||
var addEventListener;
|
||||
|
||||
var el = document.createElement('div');
|
||||
if (!('addEventListener' in el)) {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.attachEvent('on' + eventName, callback);
|
||||
};
|
||||
} else {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.addEventListener(eventName, callback, false);
|
||||
};
|
||||
}
|
||||
|
||||
if (navigator.clipboard) {
|
||||
document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
|
||||
removeClass(element, 'hidden');
|
||||
element.addEventListener('click', function() {
|
||||
navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
(function createTabs() {
|
||||
/* the accessibility options of this component have been defined according to: */
|
||||
/* www.w3.org/WAI/ARIA/apg/example-index/tabs/tabs-manual.html */
|
||||
var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
|
||||
|
||||
/* create the tab navigation for each group of tabs */
|
||||
for (var i = 0; i < tabGroups.length; i++) {
|
||||
var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
|
||||
var tabNavigation = document.createElement('div');
|
||||
tabNavigation.className = 'tab-navigation';
|
||||
tabNavigation.setAttribute('role', 'tablist');
|
||||
|
||||
var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
|
||||
for (var j = 0; j < tabs.length; j++) {
|
||||
var tabId = 'tab-' + i + '-' + j;
|
||||
var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
|
||||
|
||||
var tabNavigationItem = document.createElement('button');
|
||||
addClass(tabNavigationItem, 'tab-control');
|
||||
tabNavigationItem.setAttribute('data-tab-id', tabId);
|
||||
tabNavigationItem.setAttribute('role', 'tab');
|
||||
tabNavigationItem.setAttribute('aria-controls', tabId);
|
||||
if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
|
||||
if (hasClass(tabs[j], 'disabled')) {
|
||||
addClass(tabNavigationItem, 'disabled');
|
||||
}
|
||||
tabNavigationItem.innerHTML = tabTitle;
|
||||
tabNavigation.appendChild(tabNavigationItem);
|
||||
|
||||
var tabContent = tabs[j].querySelector('.tab-content');
|
||||
tabContent.parentElement.setAttribute('id', tabId);
|
||||
}
|
||||
|
||||
tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
|
||||
addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
|
||||
}
|
||||
|
||||
/* display the active tab and add the 'click' event listeners */
|
||||
for (i = 0; i < tabGroups.length; i++) {
|
||||
tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation .tab-control');
|
||||
|
||||
for (j = 0; j < tabNavigation.length; j++) {
|
||||
tabId = tabNavigation[j].getAttribute('data-tab-id');
|
||||
var tabPanel = document.getElementById(tabId);
|
||||
tabPanel.setAttribute('role', 'tabpanel');
|
||||
tabPanel.setAttribute('aria-labelledby', tabId);
|
||||
tabPanel.querySelector('.tab-title').className = 'hidden';
|
||||
|
||||
if (hasClass(tabNavigation[j], 'active')) {
|
||||
tabPanel.className = 'block';
|
||||
tabNavigation[j].setAttribute('aria-selected', 'true');
|
||||
tabNavigation[j].removeAttribute('tabindex');
|
||||
} else {
|
||||
tabPanel.className = 'hidden';
|
||||
tabNavigation[j].removeAttribute('aria-selected');
|
||||
tabNavigation[j].setAttribute('tabindex', '-1');
|
||||
}
|
||||
|
||||
tabNavigation[j].addEventListener('click', function(e) {
|
||||
var activeTab = e.target || e.srcElement;
|
||||
|
||||
/* needed because when the tab contains HTML contents, user can click */
|
||||
/* on any of those elements instead of their parent '<button>' element */
|
||||
while (activeTab.tagName.toLowerCase() !== 'button') {
|
||||
activeTab = activeTab.parentNode;
|
||||
}
|
||||
|
||||
/* get the full list of tabs through the parent of the active tab element */
|
||||
var tabNavigation = activeTab.parentNode.children;
|
||||
for (var k = 0; k < tabNavigation.length; k++) {
|
||||
var tabId = tabNavigation[k].getAttribute('data-tab-id');
|
||||
document.getElementById(tabId).className = 'hidden';
|
||||
removeClass(tabNavigation[k], 'active');
|
||||
tabNavigation[k].removeAttribute('aria-selected');
|
||||
tabNavigation[k].setAttribute('tabindex', '-1');
|
||||
}
|
||||
|
||||
addClass(activeTab, 'active');
|
||||
activeTab.setAttribute('aria-selected', 'true');
|
||||
activeTab.removeAttribute('tabindex');
|
||||
var activeTabId = activeTab.getAttribute('data-tab-id');
|
||||
document.getElementById(activeTabId).className = 'block';
|
||||
});
|
||||
}
|
||||
|
||||
tabGroups[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
})();
|
||||
|
||||
(function createToggles() {
|
||||
var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
|
||||
|
||||
for (var i = 0; i < toggles.length; i++) {
|
||||
var elementSelector = toggles[i].getAttribute('data-toggle-selector');
|
||||
var element = document.querySelector(elementSelector);
|
||||
|
||||
addClass(element, 'sf-toggle-content');
|
||||
|
||||
if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
|
||||
addClass(toggles[i], 'sf-toggle-on');
|
||||
addClass(element, 'sf-toggle-visible');
|
||||
} else {
|
||||
addClass(toggles[i], 'sf-toggle-off');
|
||||
addClass(element, 'sf-toggle-hidden');
|
||||
}
|
||||
|
||||
addEventListener(toggles[i], 'click', function(e) {
|
||||
var toggle = e.currentTarget;
|
||||
|
||||
if (e.target.closest('a, span[data-clipboard-text], .sf-toggle') !== toggle) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if ('' !== window.getSelection().toString()) {
|
||||
/* Don't do anything on text selection */
|
||||
return;
|
||||
}
|
||||
|
||||
var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
|
||||
|
||||
toggleClass(toggle, 'sf-toggle-on');
|
||||
toggleClass(toggle, 'sf-toggle-off');
|
||||
toggleClass(element, 'sf-toggle-hidden');
|
||||
toggleClass(element, 'sf-toggle-visible');
|
||||
|
||||
/* the toggle doesn't change its contents when clicking on it */
|
||||
if (!toggle.hasAttribute('data-toggle-alt-content')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toggle.hasAttribute('data-toggle-original-content')) {
|
||||
toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
|
||||
}
|
||||
|
||||
var currentContent = toggle.innerHTML;
|
||||
var originalContent = toggle.getAttribute('data-toggle-original-content');
|
||||
var altContent = toggle.getAttribute('data-toggle-alt-content');
|
||||
toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
|
||||
});
|
||||
|
||||
toggles[i].setAttribute('data-processed', 'true');
|
||||
}
|
||||
})();
|
||||
|
||||
(function createFilters() {
|
||||
document.querySelectorAll('[data-filters] [data-filter]').forEach(function (filter) {
|
||||
var filters = filter.closest('[data-filters]'),
|
||||
type = 'choice',
|
||||
name = filter.dataset.filter,
|
||||
ucName = name.charAt(0).toUpperCase()+name.slice(1),
|
||||
list = document.createElement('ul'),
|
||||
values = filters.dataset['filter'+ucName] || filters.querySelectorAll('[data-filter-'+name+']'),
|
||||
labels = {},
|
||||
defaults = null,
|
||||
indexed = {},
|
||||
processed = {};
|
||||
if (typeof values === 'string') {
|
||||
type = 'level';
|
||||
labels = values.split(',');
|
||||
values = values.toLowerCase().split(',');
|
||||
defaults = values.length - 1;
|
||||
}
|
||||
addClass(list, 'filter-list');
|
||||
addClass(list, 'filter-list-'+type);
|
||||
values.forEach(function (value, i) {
|
||||
if (value instanceof HTMLElement) {
|
||||
value = value.dataset['filter'+ucName];
|
||||
}
|
||||
if (value in processed) {
|
||||
return;
|
||||
}
|
||||
var option = document.createElement('li'),
|
||||
label = i in labels ? labels[i] : value,
|
||||
active = false,
|
||||
matches;
|
||||
if ('' === label) {
|
||||
option.innerHTML = '<em>(none)</em>';
|
||||
} else {
|
||||
option.innerText = label;
|
||||
}
|
||||
option.dataset.filter = value;
|
||||
option.setAttribute('title', 1 === (matches = filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').length) ? 'Matches 1 row' : 'Matches '+matches+' rows');
|
||||
indexed[value] = i;
|
||||
list.appendChild(option);
|
||||
addEventListener(option, 'click', function () {
|
||||
if ('choice' === type) {
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (option.dataset.filter === row.dataset['filter'+ucName]) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
toggleClass(option, 'active');
|
||||
} else if ('level' === type) {
|
||||
if (i === this.parentNode.querySelectorAll('.active').length - 1) {
|
||||
return;
|
||||
}
|
||||
this.parentNode.querySelectorAll('li').forEach(function (currentOption, j) {
|
||||
if (j <= i) {
|
||||
addClass(currentOption, 'active');
|
||||
if (i === j) {
|
||||
addClass(currentOption, 'last-active');
|
||||
} else {
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
} else {
|
||||
removeClass(currentOption, 'active');
|
||||
removeClass(currentOption, 'last-active');
|
||||
}
|
||||
});
|
||||
filters.querySelectorAll('[data-filter-'+name+']').forEach(function (row) {
|
||||
if (i < indexed[row.dataset['filter'+ucName]]) {
|
||||
addClass(row, 'filter-hidden-'+name);
|
||||
} else {
|
||||
removeClass(row, 'filter-hidden-'+name);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if ('choice' === type) {
|
||||
active = null === defaults || 0 <= defaults.indexOf(value);
|
||||
} else if ('level' === type) {
|
||||
active = i <= defaults;
|
||||
if (active && i === defaults) {
|
||||
addClass(option, 'last-active');
|
||||
}
|
||||
}
|
||||
if (active) {
|
||||
addClass(option, 'active');
|
||||
} else {
|
||||
filters.querySelectorAll('[data-filter-'+name+'="'+value+'"]').forEach(function (row) {
|
||||
toggleClass(row, 'filter-hidden-'+name);
|
||||
});
|
||||
}
|
||||
processed[value] = true;
|
||||
});
|
||||
|
||||
if (1 < list.childNodes.length) {
|
||||
filter.appendChild(list);
|
||||
filter.dataset.filtered = '';
|
||||
}
|
||||
});
|
||||
})();
|
||||
})();
|
||||
/*]]>*/
|
||||
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env php
|
||||
<?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.
|
||||
*/
|
||||
|
||||
if ('cli' !== \PHP_SAPI) {
|
||||
throw new Exception('This script must be run from the command line.');
|
||||
}
|
||||
|
||||
// Run from the root of the php-src repository, this script generates
|
||||
// a table with all the methods that have a tentative return type.
|
||||
//
|
||||
// Usage: find -name *.stub.php | sort | /path/to/extract-tentative-return-types.php > /path/to/TentativeTypes.php
|
||||
|
||||
echo <<<EOPHP
|
||||
<?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\ErrorHandler\Internal;
|
||||
|
||||
/**
|
||||
* This class has been generated by extract-tentative-return-types.php.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TentativeTypes
|
||||
{
|
||||
public const RETURN_TYPES = [
|
||||
|
||||
EOPHP;
|
||||
|
||||
while (false !== $file = fgets(\STDIN)) {
|
||||
$code = file_get_contents(substr($file, 0, -1));
|
||||
|
||||
if (!str_contains($code, '@tentative-return-type')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$code = preg_split('{^\s*(?:(?:abstract )?class|interface|trait) ([^\s]++)}m', $code, -1, \PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
if (1 === count($code)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for ($i = 1; null !== $class = $code[$i] ?? null; $i += 2) {
|
||||
$methods = $code[1 + $i];
|
||||
|
||||
if (!str_contains($methods, '@tentative-return-type')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo " '$class' => [\n";
|
||||
|
||||
preg_replace_callback('{@tentative-return-type.*?[\s]function ([^(]++)[^)]++\)\s*+:\s*+([^\n;\{]++)}s', static function ($m) {
|
||||
$m[2] = str_replace(' ', '', $m[2]);
|
||||
echo " '$m[1]' => '$m[2]',\n";
|
||||
|
||||
return '';
|
||||
}, $methods);
|
||||
|
||||
echo " ],\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo <<<EOPHP
|
||||
];
|
||||
}
|
||||
|
||||
EOPHP;
|
||||
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env php
|
||||
<?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.
|
||||
*/
|
||||
|
||||
if ('cli' !== \PHP_SAPI) {
|
||||
throw new Exception('This script must be run from the command line.');
|
||||
}
|
||||
|
||||
if (\in_array('-h', $argv) || \in_array('--help', $argv)) {
|
||||
echo implode(PHP_EOL, [
|
||||
' Patches type declarations based on "@return" PHPDoc and triggers deprecations for',
|
||||
' incompatible method declarations.',
|
||||
'',
|
||||
' This assists you to make your package compatible with Symfony 7, but it can be used',
|
||||
' for any class/package.',
|
||||
'',
|
||||
' Available configuration via environment variables:',
|
||||
' SYMFONY_PATCH_TYPE_DECLARATIONS',
|
||||
' A url-encoded string to change the behavior of the script. Available parameters:',
|
||||
' - "force": any value enables deprecation notices - can be any of:',
|
||||
' - "phpdoc" to patch only docblock annotations',
|
||||
' - "2" to add all possible return types',
|
||||
' - "1" to add return types but only to tests/final/internal/private methods',
|
||||
' - "php": the target version of PHP - e.g. "7.1" doesn\'t generate "object" types',
|
||||
' - "deprecations": "1" to trigger a deprecation notice when a child class misses a',
|
||||
' return type while the parent declares an "@return" annotation',
|
||||
'',
|
||||
' SYMFONY_PATCH_TYPE_EXCLUDE',
|
||||
' A regex matched against the full path to the class - any match will be excluded',
|
||||
'',
|
||||
' Example: "SYMFONY_PATCH_TYPE_DECLARATIONS=php=7.4 ./patch-type-declarations"',
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (false === getenv('SYMFONY_PATCH_TYPE_DECLARATIONS')) {
|
||||
putenv('SYMFONY_PATCH_TYPE_DECLARATIONS=force=2');
|
||||
echo 'No SYMFONY_PATCH_TYPE_DECLARATIONS env var set, patching type declarations in all methods (run the command with "-h" for more information).'.PHP_EOL;
|
||||
}
|
||||
|
||||
if (is_file($autoload = __DIR__.'/../../../../autoload.php')) {
|
||||
// noop
|
||||
} elseif (is_file($autoload = __DIR__.'/../../../../../../../autoload.php')) {
|
||||
// noop
|
||||
} else {
|
||||
echo PHP_EOL.' /!\ Cannot find the Composer autoloader, did you forget to run "composer install"?'.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (is_file($phpunitAutoload = dirname($autoload).'/bin/.phpunit/phpunit/vendor/autoload.php')) {
|
||||
require $phpunitAutoload;
|
||||
}
|
||||
|
||||
$loader = require $autoload;
|
||||
|
||||
Symfony\Component\ErrorHandler\DebugClassLoader::enable();
|
||||
|
||||
$deprecations = [];
|
||||
set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$deprecations) {
|
||||
if (\E_USER_DEPRECATED !== $type) {
|
||||
return;
|
||||
}
|
||||
|
||||
[,,,,, $class,] = explode('"', $msg);
|
||||
$deprecations[$class][] = $msg;
|
||||
});
|
||||
|
||||
$exclude = getenv('SYMFONY_PATCH_TYPE_EXCLUDE') ?: null;
|
||||
foreach ($loader->getClassMap() as $class => $file) {
|
||||
if (str_contains($file = realpath($file), \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($exclude && preg_match($exclude, $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
class_exists($class);
|
||||
}
|
||||
|
||||
Symfony\Component\ErrorHandler\DebugClassLoader::checkClasses();
|
||||
|
||||
foreach ($deprecations as $class => $classDeprecations) {
|
||||
echo $class.' ('.\count($classDeprecations).')'.PHP_EOL;
|
||||
echo implode(PHP_EOL, $classDeprecations).PHP_EOL.PHP_EOL;
|
||||
}
|
||||
|
||||
if ($deprecations && str_contains(getenv('SYMFONY_PATCH_TYPE_DECLARATIONS') ?? '', 'force')) {
|
||||
echo 'These deprecations might be fixed by the patch script, run this again to check for type deprecations.'.PHP_EOL;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="<?= $this->charset; ?>" />
|
||||
<meta name="robots" content="noindex,nofollow,noarchive" />
|
||||
<title>An Error Occurred: <?= $statusText; ?></title>
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>❌</text></svg>" />
|
||||
<style><?= $this->include('assets/css/error.css'); ?></style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Oops! An Error Occurred</h1>
|
||||
<h2>The server returned a "<?= $statusCode; ?> <?= $statusText; ?>".</h2>
|
||||
|
||||
<p>
|
||||
Something is broken. Please let us know what you were doing when this error occurred.
|
||||
We will fix it as soon as possible. Sorry for any inconvenience caused.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,115 @@
|
||||
<div class="exception-summary <?= !$exceptionMessage ? 'exception-without-message' : ''; ?>">
|
||||
<div class="exception-metadata">
|
||||
<div class="container">
|
||||
<h2 class="exception-hierarchy">
|
||||
<?php foreach (array_reverse($exception->getAllPrevious(), true) as $index => $previousException) { ?>
|
||||
<a href="#trace-box-<?= $index + 2; ?>"><?= $this->abbrClass($previousException->getClass()); ?></a>
|
||||
<span class="icon"><?= $this->include('assets/images/chevron-right.svg'); ?></span>
|
||||
<?php } ?>
|
||||
<a href="#trace-box-1"><?= $this->abbrClass($exception->getClass()); ?></a>
|
||||
</h2>
|
||||
<h2 class="exception-http">
|
||||
HTTP <?= $statusCode; ?> <small><?= $statusText; ?></small>
|
||||
</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="exception-message-wrapper">
|
||||
<div class="container">
|
||||
<h1 class="break-long-words exception-message<?= mb_strlen($exceptionMessage) > 180 ? ' long' : ''; ?>"><?= $this->formatFileFromText(nl2br($exceptionMessage)); ?></h1>
|
||||
|
||||
<div class="exception-illustration hidden-xs-down">
|
||||
<?= $this->include('assets/images/symfony-ghost.svg.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="sf-tabs">
|
||||
<div class="tab">
|
||||
<?php
|
||||
$exceptionAsArray = $exception->toArray();
|
||||
$exceptionWithUserCode = [];
|
||||
$exceptionAsArrayCount = count($exceptionAsArray);
|
||||
$last = $exceptionAsArrayCount - 1;
|
||||
foreach ($exceptionAsArray as $i => $e) {
|
||||
foreach ($e['trace'] as $trace) {
|
||||
if ($trace['file'] && !str_contains($trace['file'], '/vendor/') && !str_contains($trace['file'], '/var/cache/') && $i < $last) {
|
||||
$exceptionWithUserCode[] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<h3 class="tab-title">
|
||||
<?php if ($exceptionAsArrayCount > 1) { ?>
|
||||
Exceptions <span class="badge"><?= $exceptionAsArrayCount; ?></span>
|
||||
<?php } else { ?>
|
||||
Exception
|
||||
<?php } ?>
|
||||
</h3>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php
|
||||
foreach ($exceptionAsArray as $i => $e) {
|
||||
echo $this->include('views/traces.html.php', [
|
||||
'exception' => $e,
|
||||
'index' => $i + 1,
|
||||
'expand' => in_array($i, $exceptionWithUserCode, true) || ([] === $exceptionWithUserCode && 0 === $i),
|
||||
]);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($logger) { ?>
|
||||
<div class="tab <?= !$logger->getLogs() ? 'disabled' : ''; ?>">
|
||||
<h3 class="tab-title">
|
||||
Logs
|
||||
<?php if ($logger->countErrors()) { ?><span class="badge status-error"><?= $logger->countErrors(); ?></span><?php } ?>
|
||||
</h3>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php if ($logger->getLogs()) { ?>
|
||||
<?= $this->include('views/logs.html.php', ['logs' => $logger->getLogs()]); ?>
|
||||
<?php } else { ?>
|
||||
<div class="empty">
|
||||
<p>No log messages</p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="tab">
|
||||
<h3 class="tab-title">
|
||||
<?php if ($exceptionAsArrayCount > 1) { ?>
|
||||
Stack Traces <span class="badge"><?= $exceptionAsArrayCount; ?></span>
|
||||
<?php } else { ?>
|
||||
Stack Trace
|
||||
<?php } ?>
|
||||
</h3>
|
||||
|
||||
<div class="tab-content">
|
||||
<?php
|
||||
foreach ($exceptionAsArray as $i => $e) {
|
||||
echo $this->include('views/traces_text.html.php', [
|
||||
'exception' => $e,
|
||||
'index' => $i + 1,
|
||||
'numExceptions' => $exceptionAsArrayCount,
|
||||
]);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($currentContent) { ?>
|
||||
<div class="tab">
|
||||
<h3 class="tab-title">Output content</h3>
|
||||
|
||||
<div class="tab-content">
|
||||
<?= $currentContent; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,42 @@
|
||||
<!-- <?= $_message = \sprintf('%s (%d %s)', $exceptionMessage, $statusCode, $statusText); ?> -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="<?= $this->charset; ?>" />
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title><?= $_message; ?></title>
|
||||
<link rel="icon" type="image/png" href="<?= $this->include('assets/images/favicon.png.base64'); ?>" />
|
||||
<style><?= $this->include('assets/css/exception.css'); ?></style>
|
||||
<style><?= $this->include('assets/css/exception_full.css'); ?></style>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
document.body.classList.add(
|
||||
localStorage.getItem('symfony/profiler/theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'theme-dark' : 'theme-light')
|
||||
);
|
||||
</script>
|
||||
|
||||
<?php if (class_exists(\Composer\InstalledVersions::class) && \Composer\InstalledVersions::isInstalled('symfony/http-kernel')) { ?>
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1 class="logo"><?= $this->include('assets/images/symfony-logo.svg'); ?> Symfony Exception</h1>
|
||||
|
||||
<div class="help-link">
|
||||
<a href="https://symfony.com/doc/<?= preg_match('/^v?(\d+\.\d+)/', \Composer\InstalledVersions::getPrettyVersion('symfony/http-kernel') ?? \Composer\InstalledVersions::getPrettyVersion('symfony/symfony'), $m) ? $m[1] : 'current'; ?>/index.html">
|
||||
<span class="icon"><?= $this->include('assets/images/icon-book.svg'); ?></span>
|
||||
<span class="hidden-xs-down">Symfony</span> Docs
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<?php } ?>
|
||||
|
||||
<?= $this->include('views/exception.html.php', $context); ?>
|
||||
|
||||
<script>
|
||||
<?= $this->include('assets/js/exception.js'); ?>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!-- <?= $_message; ?> -->
|
||||
@@ -0,0 +1,45 @@
|
||||
<table class="logs" data-filter-level="Emergency,Alert,Critical,Error,Warning,Notice,Info,Debug" data-filters>
|
||||
<?php $channelIsDefined = isset($logs[0]['channel']); ?>
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-filter="level">Level</th>
|
||||
<?php if ($channelIsDefined) { ?><th data-filter="channel">Channel</th><?php } ?>
|
||||
<th class="full-width">Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($logs as $log) {
|
||||
if ($log['priority'] >= 400) {
|
||||
$status = 'error';
|
||||
} elseif ($log['priority'] >= 300) {
|
||||
$status = 'warning';
|
||||
} else {
|
||||
$severity = 0;
|
||||
if (($exception = $log['context']['exception'] ?? null) instanceof \ErrorException || $exception instanceof \Symfony\Component\ErrorHandler\Exception\SilencedErrorContext) {
|
||||
$severity = $exception->getSeverity();
|
||||
}
|
||||
$status = \E_DEPRECATED === $severity || \E_USER_DEPRECATED === $severity ? 'warning' : 'normal';
|
||||
} ?>
|
||||
<tr class="status-<?= $status; ?>" data-filter-level="<?= strtolower($this->escape($log['priorityName'])); ?>"<?php if ($channelIsDefined) { ?> data-filter-channel="<?= $this->escape($log['channel']); ?>"<?php } ?>>
|
||||
<td class="text-small nowrap">
|
||||
<span class="colored text-bold"><?= $this->escape($log['priorityName']); ?></span>
|
||||
<span class="text-muted newline"><?= date('H:i:s', $log['timestamp']); ?></span>
|
||||
</td>
|
||||
<?php if ($channelIsDefined) { ?>
|
||||
<td class="text-small text-bold nowrap">
|
||||
<?= $this->escape($log['channel']); ?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<td>
|
||||
<?= $this->formatLogMessage($log['message'], $log['context']); ?>
|
||||
<?php if ($log['context']) { ?>
|
||||
<pre class="text-muted prewrap m-t-5"><?= $this->escape(json_encode($log['context'], \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES)); ?></pre>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,43 @@
|
||||
<div class="trace-line-header break-long-words <?= $trace['file'] ? 'sf-toggle' : ''; ?>" data-toggle-selector="#trace-html-<?= $prefix; ?>-<?= $i; ?>" data-toggle-initial="<?= 'expanded' === $style ? 'display' : ''; ?>">
|
||||
<?php if ($trace['file']) { ?>
|
||||
<span class="icon icon-close"><?= $this->include('assets/images/icon-minus-square.svg'); ?></span>
|
||||
<span class="icon icon-open"><?= $this->include('assets/images/icon-plus-square.svg'); ?></span>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ('compact' !== $style && $trace['function']) { ?>
|
||||
<span class="trace-class"><?= $this->abbrClass($trace['class']); ?></span><?php if ($trace['type']) { ?><span class="trace-type"><?= $trace['type']; ?></span><?php } ?><span class="trace-method"><?= $trace['function']; ?></span><?php if (isset($trace['args'])) { ?><span class="trace-arguments">(<?= $this->formatArgs($trace['args']); ?>)</span><?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($trace['file']) { ?>
|
||||
<?php
|
||||
$lineNumber = $trace['line'] ?: 1;
|
||||
$fileLink = $this->fileLinkFormat->format($trace['file'], $lineNumber);
|
||||
$filePath = strtr(strip_tags($this->formatFile($trace['file'], $lineNumber)), [' at line '.$lineNumber => '']);
|
||||
$filePathParts = explode(\DIRECTORY_SEPARATOR, $filePath);
|
||||
?>
|
||||
<span class="block trace-file-path">
|
||||
in
|
||||
<a href="<?= $fileLink; ?>">
|
||||
<?= implode(\DIRECTORY_SEPARATOR, array_slice($filePathParts, 0, -1)).\DIRECTORY_SEPARATOR; ?><strong><?= end($filePathParts); ?></strong>
|
||||
</a>
|
||||
<?php if ('compact' === $style && $trace['function']) { ?>
|
||||
<span class="trace-type"><?= $trace['type']; ?></span>
|
||||
<span class="trace-method"><?= $trace['function']; ?></span>
|
||||
<?php } ?>
|
||||
(line <?= $lineNumber; ?>)
|
||||
<span class="icon icon-copy hidden" data-clipboard-text="<?php echo implode(\DIRECTORY_SEPARATOR, $filePathParts).':'.$lineNumber; ?>">
|
||||
<?php echo $this->include('assets/images/icon-copy.svg'); ?>
|
||||
</span>
|
||||
</span>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php if ($trace['file']) { ?>
|
||||
<div id="trace-html-<?= $prefix.'-'.$i; ?>" class="trace-code sf-toggle-content">
|
||||
<?= strtr($this->fileExcerpt($trace['file'], $trace['line'], 5), [
|
||||
'#DD0000' => 'var(--highlight-string)',
|
||||
'#007700' => 'var(--highlight-keyword)',
|
||||
'#0000BB' => 'var(--highlight-default)',
|
||||
'#FF8000' => 'var(--highlight-comment)',
|
||||
]); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
@@ -0,0 +1,59 @@
|
||||
<div class="trace trace-as-html" id="trace-box-<?= $index; ?>">
|
||||
<div class="trace-details">
|
||||
<div class="trace-head">
|
||||
<div class="sf-toggle" data-toggle-selector="#trace-html-<?= $index; ?>" data-toggle-initial="<?= $expand ? 'display' : ''; ?>">
|
||||
<span class="icon icon-close"><?= $this->include('assets/images/icon-minus-square-o.svg'); ?></span>
|
||||
<span class="icon icon-open"><?= $this->include('assets/images/icon-plus-square-o.svg'); ?></span>
|
||||
<?php
|
||||
$separator = strrpos($exception['class'], '\\');
|
||||
$separator = false === $separator ? 0 : $separator + 1;
|
||||
|
||||
$namespace = substr($exception['class'], 0, $separator);
|
||||
$class = substr($exception['class'], $separator);
|
||||
?>
|
||||
<?php if ('' === $class) { ?>
|
||||
<br>
|
||||
<?php } else { ?>
|
||||
<h3 class="trace-class">
|
||||
<?php if ('' !== $namespace) { ?>
|
||||
<span class="trace-namespace"><?= $namespace; ?></span>
|
||||
<?php } ?>
|
||||
<?= $class; ?>
|
||||
</h3>
|
||||
<?php } ?>
|
||||
<?php if ($exception['message'] && $index > 1) { ?>
|
||||
<p class="break-long-words trace-message"><?= $this->escape($exception['message']); ?></p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php if (\count($exception['data'] ?? [])) { ?>
|
||||
<details class="exception-properties-wrapper">
|
||||
<summary>Show exception properties</summary>
|
||||
<div class="exception-properties">
|
||||
<?= $this->dumpValue($exception['data']) ?>
|
||||
</div>
|
||||
</details>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div id="trace-html-<?= $index; ?>" class="sf-toggle-content">
|
||||
<?php
|
||||
$isFirstUserCode = true;
|
||||
foreach ($exception['trace'] as $i => $trace) {
|
||||
$isVendorTrace = $trace['file'] && (str_contains($trace['file'], '/vendor/') || str_contains($trace['file'], '/var/cache/'));
|
||||
$displayCodeSnippet = $isFirstUserCode && !$isVendorTrace;
|
||||
if ($displayCodeSnippet) {
|
||||
$isFirstUserCode = false;
|
||||
} ?>
|
||||
<div class="trace-line <?= $isVendorTrace ? 'trace-from-vendor' : ''; ?>">
|
||||
<?= $this->include('views/trace.html.php', [
|
||||
'prefix' => $index,
|
||||
'i' => $i,
|
||||
'trace' => $trace,
|
||||
'style' => $isVendorTrace ? 'compact' : ($displayCodeSnippet ? 'expanded' : ''),
|
||||
]); ?>
|
||||
</div>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
<table class="trace trace-as-text">
|
||||
<thead class="trace-head">
|
||||
<tr>
|
||||
<th class="sf-toggle" data-toggle-selector="#trace-text-<?= $index; ?>" data-toggle-initial="<?= 1 === $index ? 'display' : ''; ?>">
|
||||
<div class="trace-class">
|
||||
<?php if ($numExceptions > 1) { ?>
|
||||
<span class="text-muted">[<?= $numExceptions - $index + 1; ?>/<?= $numExceptions; ?>]</span>
|
||||
<?php } ?>
|
||||
<?= ($parts = explode('\\', $exception['class'])) ? end($parts) : ''; ?>
|
||||
<span class="icon icon-close"><?= $this->include('assets/images/icon-minus-square-o.svg'); ?></span>
|
||||
<span class="icon icon-open"><?= $this->include('assets/images/icon-plus-square-o.svg'); ?></span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="trace-text-<?= $index; ?>">
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ($exception['trace']) { ?>
|
||||
<pre class="stacktrace">
|
||||
<?php
|
||||
echo $this->escape($exception['class']).":\n";
|
||||
if ($exception['message']) {
|
||||
echo $this->escape($exception['message'])."\n";
|
||||
}
|
||||
|
||||
foreach ($exception['trace'] as $trace) {
|
||||
echo "\n ";
|
||||
if ($trace['function']) {
|
||||
echo $this->escape('at '.$trace['class'].$trace['type'].$trace['function']).'('.(isset($trace['args']) ? $this->formatArgsAsText($trace['args']) : '').')';
|
||||
}
|
||||
if ($trace['file'] && $trace['line']) {
|
||||
echo($trace['function'] ? "\n (" : 'at ').strtr(strip_tags($this->formatFile($trace['file'], $trace['line'])), [' at line '.$trace['line'] => '']).':'.$trace['line'].($trace['function'] ? ')' : '');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?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\ErrorHandler;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ThrowableUtils
|
||||
{
|
||||
public static function getSeverity(SilencedErrorContext|\Throwable $throwable): int
|
||||
{
|
||||
if ($throwable instanceof \ErrorException || $throwable instanceof SilencedErrorContext) {
|
||||
return $throwable->getSeverity();
|
||||
}
|
||||
|
||||
if ($throwable instanceof \ParseError) {
|
||||
return \E_PARSE;
|
||||
}
|
||||
|
||||
if ($throwable instanceof \TypeError) {
|
||||
return \E_RECOVERABLE_ERROR;
|
||||
}
|
||||
|
||||
return \E_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "symfony/error-handler",
|
||||
"type": "library",
|
||||
"description": "Provides tools to manage errors and ease debugging PHP code",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.4.1",
|
||||
"psr/log": "^1|^2|^3",
|
||||
"symfony/polyfill-php85": "^1.32",
|
||||
"symfony/var-dumper": "^7.4|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "^7.4|^8.0",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"symfony/http-kernel": "^7.4|^8.0",
|
||||
"symfony/serializer": "^7.4|^8.0",
|
||||
"symfony/webpack-encore-bundle": "^1.0|^2.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/deprecation-contracts": "<2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\ErrorHandler\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"bin": [
|
||||
"Resources/bin/patch-type-declarations"
|
||||
],
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||