mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Update to laravel 7
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Symfony\Component\HttpKernel\DataCollector;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
@@ -26,7 +27,7 @@ use Symfony\Component\VarDumper\Server\Connection;
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @final since Symfony 4.3
|
||||
* @final
|
||||
*/
|
||||
class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
{
|
||||
@@ -43,6 +44,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
private $sourceContextProvider;
|
||||
|
||||
/**
|
||||
* @param string|FileLinkFormatter|null $fileLinkFormat
|
||||
* @param DataDumperInterface|Connection|null $dumper
|
||||
*/
|
||||
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null)
|
||||
@@ -75,7 +77,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->stopwatch->start('dump');
|
||||
}
|
||||
|
||||
list('name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt) = $this->sourceContextProvider->getContext();
|
||||
['name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt] = $this->sourceContextProvider->getContext();
|
||||
|
||||
if ($this->dumper instanceof Connection) {
|
||||
if (!$this->dumper->write($data)) {
|
||||
@@ -98,14 +100,14 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
// Sub-requests and programmatic calls stay in the collected profile.
|
||||
if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
|
||||
if ($this->dumper || ($this->requestStack && $this->requestStack->getMainRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,11 +115,11 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
if (!$this->requestStack
|
||||
|| !$response->headers->has('X-Debug-Token')
|
||||
|| $response->isRedirection()
|
||||
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|
||||
|| ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html'))
|
||||
|| 'html' !== $request->getRequestFormat()
|
||||
|| false === strripos($response->getContent(), '</body>')
|
||||
) {
|
||||
if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) {
|
||||
if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type'), 'html')) {
|
||||
$dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
} else {
|
||||
@@ -148,7 +150,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
if (!$this->dataCount) {
|
||||
$this->data = [];
|
||||
@@ -176,24 +178,29 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$charset = array_pop($this->data);
|
||||
$fileLinkFormat = array_pop($this->data);
|
||||
$this->dataCount = \count($this->data);
|
||||
foreach ($this->data as $dump) {
|
||||
if (!\is_string($dump['name']) || !\is_string($dump['file']) || !\is_int($dump['line'])) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
}
|
||||
}
|
||||
|
||||
self::__construct($this->stopwatch, $fileLinkFormat, $charset);
|
||||
self::__construct($this->stopwatch, \is_string($fileLinkFormat) || $fileLinkFormat instanceof FileLinkFormatter ? $fileLinkFormat : null, \is_string($charset) ? $charset : null);
|
||||
}
|
||||
|
||||
public function getDumpsCount()
|
||||
public function getDumpsCount(): int
|
||||
{
|
||||
return $this->dataCount;
|
||||
}
|
||||
|
||||
public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
|
||||
public function getDumps(string $format, int $maxDepthLimit = -1, int $maxItemsPerDepth = -1): array
|
||||
{
|
||||
$data = fopen('php://memory', 'r+b');
|
||||
$data = fopen('php://memory', 'r+');
|
||||
|
||||
if ('html' === $format) {
|
||||
$dumper = new HtmlDumper($data, $this->charset);
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid dump format: %s', $format));
|
||||
throw new \InvalidArgumentException(sprintf('Invalid dump format: "%s".', $format));
|
||||
}
|
||||
$dumps = [];
|
||||
|
||||
@@ -212,7 +219,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
return $dumps;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'dump';
|
||||
}
|
||||
@@ -230,13 +237,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
--$i;
|
||||
}
|
||||
|
||||
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
|
||||
$html = 'html' === $_SERVER['VAR_DUMPER_FORMAT'];
|
||||
} else {
|
||||
$html = !\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html');
|
||||
}
|
||||
|
||||
if ($html) {
|
||||
if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) && stripos($h[$i], 'html')) {
|
||||
$dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]);
|
||||
} else {
|
||||
@@ -256,7 +257,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function doDump(DataDumperInterface $dumper, $data, $name, $file, $line)
|
||||
private function doDump(DataDumperInterface $dumper, Data $data, string $name, string $file, int $line)
|
||||
{
|
||||
if ($dumper instanceof CliDumper) {
|
||||
$contextDumper = function ($name, $file, $line, $fmt) {
|
||||
|
||||
Reference in New Issue
Block a user