Laravel 5.6 updates
Travis config update Removed HHVM script as Laravel no longer support HHVM after releasing 5.3
This commit is contained in:
@@ -18,9 +18,10 @@ use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider;
|
||||
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
|
||||
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
use Twig\Template;
|
||||
use Symfony\Component\VarDumper\Server\Connection;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
@@ -37,16 +38,18 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
private $charset;
|
||||
private $requestStack;
|
||||
private $dumper;
|
||||
private $dumperIsInjected;
|
||||
private $sourceContextProvider;
|
||||
|
||||
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null)
|
||||
/**
|
||||
* @param DataDumperInterface|Connection|null $dumper
|
||||
*/
|
||||
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, string $charset = null, RequestStack $requestStack = null, $dumper = null)
|
||||
{
|
||||
$this->stopwatch = $stopwatch;
|
||||
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
|
||||
$this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8';
|
||||
$this->requestStack = $requestStack;
|
||||
$this->dumper = $dumper;
|
||||
$this->dumperIsInjected = null !== $dumper;
|
||||
|
||||
// All clones share these properties by reference:
|
||||
$this->rootRefs = array(
|
||||
@@ -55,6 +58,8 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
&$this->isCollected,
|
||||
&$this->clonesCount,
|
||||
);
|
||||
|
||||
$this->sourceContextProvider = $dumper instanceof Connection && isset($dumper->getContextProviders()['source']) ? $dumper->getContextProviders()['source'] : new SourceContextProvider($this->charset);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
@@ -67,65 +72,17 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
if ($this->stopwatch) {
|
||||
$this->stopwatch->start('dump');
|
||||
}
|
||||
if ($this->isCollected && !$this->dumper) {
|
||||
$this->isCollected = false;
|
||||
}
|
||||
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS, 7);
|
||||
list('name' => $name, 'file' => $file, 'line' => $line, 'file_excerpt' => $fileExcerpt) = $this->sourceContextProvider->getContext();
|
||||
|
||||
$file = $trace[0]['file'];
|
||||
$line = $trace[0]['line'];
|
||||
$name = false;
|
||||
$fileExcerpt = false;
|
||||
|
||||
for ($i = 1; $i < 7; ++$i) {
|
||||
if (isset($trace[$i]['class'], $trace[$i]['function'])
|
||||
&& 'dump' === $trace[$i]['function']
|
||||
&& 'Symfony\Component\VarDumper\VarDumper' === $trace[$i]['class']
|
||||
) {
|
||||
$file = $trace[$i]['file'];
|
||||
$line = $trace[$i]['line'];
|
||||
|
||||
while (++$i < 7) {
|
||||
if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && 0 !== strpos($trace[$i]['function'], 'call_user_func')) {
|
||||
$file = $trace[$i]['file'];
|
||||
$line = $trace[$i]['line'];
|
||||
|
||||
break;
|
||||
} elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof Template) {
|
||||
$template = $trace[$i]['object'];
|
||||
$name = $template->getTemplateName();
|
||||
$src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false);
|
||||
$info = $template->getDebugInfo();
|
||||
if (isset($info[$trace[$i - 1]['line']])) {
|
||||
$line = $info[$trace[$i - 1]['line']];
|
||||
$file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : null;
|
||||
|
||||
if ($src) {
|
||||
$src = explode("\n", $src);
|
||||
$fileExcerpt = array();
|
||||
|
||||
for ($i = max($line - 3, 1), $max = min($line + 3, \count($src)); $i <= $max; ++$i) {
|
||||
$fileExcerpt[] = '<li'.($i === $line ? ' class="selected"' : '').'><code>'.$this->htmlEncode($src[$i - 1]).'</code></li>';
|
||||
}
|
||||
|
||||
$fileExcerpt = '<ol start="'.max($line - 3, 1).'">'.implode("\n", $fileExcerpt).'</ol>';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if ($this->dumper instanceof Connection) {
|
||||
if (!$this->dumper->write($data)) {
|
||||
$this->isCollected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (false === $name) {
|
||||
$name = str_replace('\\', '/', $file);
|
||||
$name = substr($name, strrpos($name, '/') + 1);
|
||||
}
|
||||
|
||||
if ($this->dumper) {
|
||||
$this->doDump($data, $name, $file, $line);
|
||||
} elseif ($this->dumper) {
|
||||
$this->doDump($this->dumper, $data, $name, $file, $line);
|
||||
} else {
|
||||
$this->isCollected = false;
|
||||
}
|
||||
|
||||
$this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt');
|
||||
@@ -152,14 +109,14 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
|| false === strripos($response->getContent(), '</body>')
|
||||
) {
|
||||
if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) {
|
||||
$this->dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat));
|
||||
$dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat));
|
||||
} else {
|
||||
$this->dumper = new CliDumper('php://output', $this->charset);
|
||||
$dumper = new CliDumper('php://output', $this->charset);
|
||||
}
|
||||
|
||||
foreach ($this->data as $dump) {
|
||||
$this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']);
|
||||
$this->doDump($dumper, $dump['data'], $dump['name'], $dump['file'], $dump['line']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,9 +145,6 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
$this->data = array();
|
||||
$this->dataCount = 0;
|
||||
$this->isCollected = true;
|
||||
if (!$this->dumperIsInjected) {
|
||||
$this->dumper = null;
|
||||
}
|
||||
|
||||
return $ser;
|
||||
}
|
||||
@@ -251,15 +205,15 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
|
||||
if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true) && stripos($h[$i], 'html')) {
|
||||
$this->dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$this->dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat));
|
||||
$dumper = new HtmlDumper('php://output', $this->charset);
|
||||
$dumper->setDisplayOptions(array('fileLinkFormat' => $this->fileLinkFormat));
|
||||
} else {
|
||||
$this->dumper = new CliDumper('php://output', $this->charset);
|
||||
$dumper = new CliDumper('php://output', $this->charset);
|
||||
}
|
||||
|
||||
foreach ($this->data as $i => $dump) {
|
||||
$this->data[$i] = null;
|
||||
$this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']);
|
||||
$this->doDump($dumper, $dump['data'], $dump['name'], $dump['file'], $dump['line']);
|
||||
}
|
||||
|
||||
$this->data = array();
|
||||
@@ -267,9 +221,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
}
|
||||
|
||||
private function doDump($data, $name, $file, $line)
|
||||
private function doDump(DataDumperInterface $dumper, $data, $name, $file, $line)
|
||||
{
|
||||
if ($this->dumper instanceof CliDumper) {
|
||||
if ($dumper instanceof CliDumper) {
|
||||
$contextDumper = function ($name, $file, $line, $fmt) {
|
||||
if ($this instanceof HtmlDumper) {
|
||||
if ($file) {
|
||||
@@ -290,26 +244,12 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
||||
}
|
||||
$this->dumpLine(0);
|
||||
};
|
||||
$contextDumper = $contextDumper->bindTo($this->dumper, $this->dumper);
|
||||
$contextDumper = $contextDumper->bindTo($dumper, $dumper);
|
||||
$contextDumper($name, $file, $line, $this->fileLinkFormat);
|
||||
} else {
|
||||
$cloner = new VarCloner();
|
||||
$this->dumper->dump($cloner->cloneVar($name.' on line '.$line.':'));
|
||||
$dumper->dump($cloner->cloneVar($name.' on line '.$line.':'));
|
||||
}
|
||||
$this->dumper->dump($data);
|
||||
}
|
||||
|
||||
private function htmlEncode($s)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
$dumper = new HtmlDumper(function ($line) use (&$html) { $html .= $line; }, $this->charset);
|
||||
$dumper->setDumpHeader('');
|
||||
$dumper->setDumpBoundaries('', '');
|
||||
|
||||
$cloner = new VarCloner();
|
||||
$dumper->dump($cloner->cloneVar($s));
|
||||
|
||||
return substr(strip_tags($html), 1, -1);
|
||||
$dumper->dump($data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user