mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace Symfony\Bundle\WebProfilerBundle\Twig;
|
||||
|
||||
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
use Twig\Environment;
|
||||
@@ -23,14 +22,11 @@ use Twig\TwigFunction;
|
||||
* Twig extension for the profiler.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WebProfilerExtension extends ProfilerExtension
|
||||
{
|
||||
/**
|
||||
* @var ValueExporter
|
||||
*/
|
||||
private $valueExporter;
|
||||
|
||||
/**
|
||||
* @var HtmlDumper
|
||||
*/
|
||||
@@ -48,38 +44,34 @@ class WebProfilerExtension extends ProfilerExtension
|
||||
|
||||
public function __construct(HtmlDumper $dumper = null)
|
||||
{
|
||||
$this->dumper = $dumper ?: new HtmlDumper();
|
||||
$this->dumper->setOutput($this->output = fopen('php://memory', 'r+b'));
|
||||
$this->dumper = $dumper ?? new HtmlDumper();
|
||||
$this->dumper->setOutput($this->output = fopen('php://memory', 'r+'));
|
||||
}
|
||||
|
||||
public function enter(Profile $profile)
|
||||
public function enter(Profile $profile): void
|
||||
{
|
||||
++$this->stackLevel;
|
||||
}
|
||||
|
||||
public function leave(Profile $profile)
|
||||
public function leave(Profile $profile): void
|
||||
{
|
||||
if (0 === --$this->stackLevel) {
|
||||
$this->dumper->setOutput($this->output = fopen('php://memory', 'r+b'));
|
||||
$this->dumper->setOutput($this->output = fopen('php://memory', 'r+'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctions()
|
||||
public function getFunctions(): array
|
||||
{
|
||||
$profilerDump = function (Environment $env, $value, $maxDepth = 0) {
|
||||
return $value instanceof Data ? $this->dumpData($env, $value, $maxDepth) : twig_escape_filter($env, $this->dumpValue($value));
|
||||
};
|
||||
|
||||
return [
|
||||
new TwigFunction('profiler_dump', $profilerDump, ['is_safe' => ['html'], 'needs_environment' => true]),
|
||||
new TwigFunction('profiler_dump', [$this, 'dumpData'], ['is_safe' => ['html'], 'needs_environment' => true]),
|
||||
new TwigFunction('profiler_dump_log', [$this, 'dumpLog'], ['is_safe' => ['html'], 'needs_environment' => true]),
|
||||
];
|
||||
}
|
||||
|
||||
public function dumpData(Environment $env, Data $data, $maxDepth = 0)
|
||||
public function dumpData(Environment $env, Data $data, int $maxDepth = 0)
|
||||
{
|
||||
$this->dumper->setCharset($env->getCharset());
|
||||
$this->dumper->dump($data, null, [
|
||||
@@ -93,12 +85,12 @@ class WebProfilerExtension extends ProfilerExtension
|
||||
return str_replace("\n</pre", '</pre', rtrim($dump));
|
||||
}
|
||||
|
||||
public function dumpLog(Environment $env, $message, Data $context = null)
|
||||
public function dumpLog(Environment $env, string $message, Data $context = null)
|
||||
{
|
||||
$message = twig_escape_filter($env, $message);
|
||||
$message = preg_replace('/"(.*?)"/', '"<b>$1</b>"', $message);
|
||||
|
||||
if (null === $context || false === strpos($message, '{')) {
|
||||
if (null === $context || !str_contains($message, '{')) {
|
||||
return '<span class="dump-inline">'.$message.'</span>';
|
||||
}
|
||||
|
||||
@@ -111,20 +103,6 @@ class WebProfilerExtension extends ProfilerExtension
|
||||
return '<span class="dump-inline">'.strtr($message, $replacements).'</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 3.2, to be removed in 4.0. Use the dumpData() method instead.
|
||||
*/
|
||||
public function dumpValue($value)
|
||||
{
|
||||
@trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use the dumpData() method instead.', __METHOD__), \E_USER_DEPRECATED);
|
||||
|
||||
if (null === $this->valueExporter) {
|
||||
$this->valueExporter = new ValueExporter();
|
||||
}
|
||||
|
||||
return $this->valueExporter->exportValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user