mirror of
https://github.com/pierre42100/comunic
synced 2025-06-19 16:45:18 +00:00
First commit
This commit is contained in:
179
developer/vendor/symfony/var-dumper/Dumper/AbstractDumper.php
vendored
Normal file
179
developer/vendor/symfony/var-dumper/Dumper/AbstractDumper.php
vendored
Normal file
@ -0,0 +1,179 @@
|
||||
<?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\VarDumper\Dumper;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
use Symfony\Component\VarDumper\Cloner\DumperInterface;
|
||||
|
||||
/**
|
||||
* Abstract mechanism for dumping a Data object.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
{
|
||||
public static $defaultOutput = 'php://output';
|
||||
|
||||
protected $line = '';
|
||||
protected $lineDumper;
|
||||
protected $outputStream;
|
||||
protected $decimalPoint; // This is locale dependent
|
||||
protected $indentPad = ' ';
|
||||
|
||||
private $charset;
|
||||
|
||||
/**
|
||||
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
|
||||
* @param string $charset The default character encoding to use for non-UTF8 strings
|
||||
*/
|
||||
public function __construct($output = null, $charset = null)
|
||||
{
|
||||
$this->setCharset($charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->decimalPoint = (string) 0.5;
|
||||
$this->decimalPoint = $this->decimalPoint[1];
|
||||
$this->setOutput($output ?: static::$defaultOutput);
|
||||
if (!$output && is_string(static::$defaultOutput)) {
|
||||
static::$defaultOutput = $this->outputStream;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the output destination of the dumps.
|
||||
*
|
||||
* @param callable|resource|string $output A line dumper callable, an opened stream or an output path
|
||||
*
|
||||
* @return callable|resource|string The previous output destination
|
||||
*/
|
||||
public function setOutput($output)
|
||||
{
|
||||
$prev = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
|
||||
|
||||
if (is_callable($output)) {
|
||||
$this->outputStream = null;
|
||||
$this->lineDumper = $output;
|
||||
} else {
|
||||
if (is_string($output)) {
|
||||
$output = fopen($output, 'wb');
|
||||
}
|
||||
$this->outputStream = $output;
|
||||
$this->lineDumper = array($this, 'echoLine');
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default character encoding to use for non-UTF8 strings.
|
||||
*
|
||||
* @param string $charset The default character encoding to use for non-UTF8 strings
|
||||
*
|
||||
* @return string The previous charset
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$prev = $this->charset;
|
||||
|
||||
$charset = strtoupper($charset);
|
||||
$charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset;
|
||||
|
||||
$this->charset = $charset;
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the indentation pad string.
|
||||
*
|
||||
* @param string $pad A string the will be prepended to dumped lines, repeated by nesting level
|
||||
*
|
||||
* @return string The indent pad
|
||||
*/
|
||||
public function setIndentPad($pad)
|
||||
{
|
||||
$prev = $this->indentPad;
|
||||
$this->indentPad = $pad;
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a Data object.
|
||||
*
|
||||
* @param Data $data A Data object
|
||||
* @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path
|
||||
*/
|
||||
public function dump(Data $data, $output = null)
|
||||
{
|
||||
$exception = null;
|
||||
if ($output) {
|
||||
$prevOutput = $this->setOutput($output);
|
||||
}
|
||||
try {
|
||||
$data->dump($this);
|
||||
$this->dumpLine(-1);
|
||||
} catch (\Exception $exception) {
|
||||
// Re-thrown below
|
||||
} catch (\Throwable $exception) {
|
||||
// Re-thrown below
|
||||
}
|
||||
if ($output) {
|
||||
$this->setOutput($prevOutput);
|
||||
}
|
||||
if (null !== $exception) {
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps the current line.
|
||||
*
|
||||
* @param int $depth The recursive depth in the dumped structure for the line being dumped
|
||||
*/
|
||||
protected function dumpLine($depth)
|
||||
{
|
||||
call_user_func($this->lineDumper, $this->line, $depth, $this->indentPad);
|
||||
$this->line = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic line dumper callback.
|
||||
*
|
||||
* @param string $line The line to write
|
||||
* @param int $depth The recursive depth in the dumped structure
|
||||
* @param string $indentPad The line indent pad
|
||||
*/
|
||||
protected function echoLine($line, $depth, $indentPad)
|
||||
{
|
||||
if (-1 !== $depth) {
|
||||
fwrite($this->outputStream, str_repeat($indentPad, $depth).$line."\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a non-UTF-8 string to UTF-8.
|
||||
*
|
||||
* @param string $s The non-UTF-8 string to convert
|
||||
*
|
||||
* @return string The string converted to UTF-8
|
||||
*/
|
||||
protected function utf8Encode($s)
|
||||
{
|
||||
if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) {
|
||||
return $c;
|
||||
}
|
||||
if ('CP1252' !== $this->charset && false !== $c = @iconv('CP1252', 'UTF-8', $s)) {
|
||||
return $c;
|
||||
}
|
||||
|
||||
return iconv('CP850', 'UTF-8', $s);
|
||||
}
|
||||
}
|
476
developer/vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
Normal file
476
developer/vendor/symfony/var-dumper/Dumper/CliDumper.php
vendored
Normal file
@ -0,0 +1,476 @@
|
||||
<?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\VarDumper\Dumper;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Cursor;
|
||||
|
||||
/**
|
||||
* CliDumper dumps variables for command line output.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class CliDumper extends AbstractDumper
|
||||
{
|
||||
public static $defaultColors;
|
||||
public static $defaultOutput = 'php://stdout';
|
||||
|
||||
protected $colors;
|
||||
protected $maxStringWidth = 0;
|
||||
protected $styles = array(
|
||||
// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||
'default' => '38;5;208',
|
||||
'num' => '1;38;5;38',
|
||||
'const' => '1;38;5;208',
|
||||
'str' => '1;38;5;113',
|
||||
'note' => '38;5;38',
|
||||
'ref' => '38;5;247',
|
||||
'public' => '',
|
||||
'protected' => '',
|
||||
'private' => '',
|
||||
'meta' => '38;5;170',
|
||||
'key' => '38;5;113',
|
||||
'index' => '38;5;38',
|
||||
);
|
||||
|
||||
protected static $controlCharsRx = '/[\x00-\x1F\x7F]+/';
|
||||
protected static $controlCharsMap = array(
|
||||
"\t" => '\t',
|
||||
"\n" => '\n',
|
||||
"\v" => '\v',
|
||||
"\f" => '\f',
|
||||
"\r" => '\r',
|
||||
"\033" => '\e',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($output = null, $charset = null)
|
||||
{
|
||||
parent::__construct($output, $charset);
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && 'ON' !== @getenv('ConEmuANSI') && 'xterm' !== @getenv('TERM')) {
|
||||
// Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI
|
||||
$this->setStyles(array(
|
||||
'default' => '31',
|
||||
'num' => '1;34',
|
||||
'const' => '1;31',
|
||||
'str' => '1;32',
|
||||
'note' => '34',
|
||||
'ref' => '1;30',
|
||||
'meta' => '35',
|
||||
'key' => '32',
|
||||
'index' => '34',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables/disables colored output.
|
||||
*
|
||||
* @param bool $colors
|
||||
*/
|
||||
public function setColors($colors)
|
||||
{
|
||||
$this->colors = (bool) $colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of characters per line for dumped strings.
|
||||
*
|
||||
* @param int $maxStringWidth
|
||||
*/
|
||||
public function setMaxStringWidth($maxStringWidth)
|
||||
{
|
||||
$this->maxStringWidth = (int) $maxStringWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures styles.
|
||||
*
|
||||
* @param array $styles A map of style names to style definitions
|
||||
*/
|
||||
public function setStyles(array $styles)
|
||||
{
|
||||
$this->styles = $styles + $this->styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpScalar(Cursor $cursor, $type, $value)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
|
||||
$style = 'const';
|
||||
$attr = array();
|
||||
|
||||
switch ($type) {
|
||||
case 'integer':
|
||||
$style = 'num';
|
||||
break;
|
||||
|
||||
case 'double':
|
||||
$style = 'num';
|
||||
|
||||
switch (true) {
|
||||
case INF === $value: $value = 'INF'; break;
|
||||
case -INF === $value: $value = '-INF'; break;
|
||||
case is_nan($value): $value = 'NAN'; break;
|
||||
default:
|
||||
$value = (string) $value;
|
||||
if (false === strpos($value, $this->decimalPoint)) {
|
||||
$value .= $this->decimalPoint.'0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'NULL':
|
||||
$value = 'null';
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
$value = $value ? 'true' : 'false';
|
||||
break;
|
||||
|
||||
default:
|
||||
$attr['value'] = isset($value[0]) && !preg_match('//u', $value) ? $this->utf8Encode($value) : $value;
|
||||
$value = isset($type[0]) && !preg_match('//u', $type) ? $this->utf8Encode($type) : $type;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->line .= $this->style($style, $value, $attr);
|
||||
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dumpString(Cursor $cursor, $str, $bin, $cut)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
|
||||
if ($bin) {
|
||||
$str = $this->utf8Encode($str);
|
||||
}
|
||||
if ('' === $str) {
|
||||
$this->line .= '""';
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
} else {
|
||||
$attr = array(
|
||||
'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0,
|
||||
'binary' => $bin,
|
||||
);
|
||||
$str = explode("\n", $str);
|
||||
if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) {
|
||||
unset($str[1]);
|
||||
$str[0] .= "\n";
|
||||
}
|
||||
$m = count($str) - 1;
|
||||
$i = $lineCut = 0;
|
||||
|
||||
if ($bin) {
|
||||
$this->line .= 'b';
|
||||
}
|
||||
|
||||
if ($m) {
|
||||
$this->line .= '"""';
|
||||
$this->dumpLine($cursor->depth);
|
||||
} else {
|
||||
$this->line .= '"';
|
||||
}
|
||||
|
||||
foreach ($str as $str) {
|
||||
if ($i < $m) {
|
||||
$str .= "\n";
|
||||
}
|
||||
if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) {
|
||||
$str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8');
|
||||
$lineCut = $len - $this->maxStringWidth;
|
||||
}
|
||||
if ($m && 0 < $cursor->depth) {
|
||||
$this->line .= $this->indentPad;
|
||||
}
|
||||
if ('' !== $str) {
|
||||
$this->line .= $this->style('str', $str, $attr);
|
||||
}
|
||||
if ($i++ == $m) {
|
||||
if ($m) {
|
||||
if ('' !== $str) {
|
||||
$this->dumpLine($cursor->depth);
|
||||
if (0 < $cursor->depth) {
|
||||
$this->line .= $this->indentPad;
|
||||
}
|
||||
}
|
||||
$this->line .= '"""';
|
||||
} else {
|
||||
$this->line .= '"';
|
||||
}
|
||||
if ($cut < 0) {
|
||||
$this->line .= '…';
|
||||
$lineCut = 0;
|
||||
} elseif ($cut) {
|
||||
$lineCut += $cut;
|
||||
}
|
||||
}
|
||||
if ($lineCut) {
|
||||
$this->line .= '…'.$lineCut;
|
||||
$lineCut = 0;
|
||||
}
|
||||
|
||||
$this->dumpLine($cursor->depth, $i > $m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
|
||||
{
|
||||
$this->dumpKey($cursor);
|
||||
|
||||
if (!preg_match('//u', $class)) {
|
||||
$class = $this->utf8Encode($class);
|
||||
}
|
||||
if (Cursor::HASH_OBJECT === $type) {
|
||||
$prefix = $class && 'stdClass' !== $class ? $this->style('note', $class).' {' : '{';
|
||||
} elseif (Cursor::HASH_RESOURCE === $type) {
|
||||
$prefix = $this->style('note', $class.' resource').($hasChild ? ' {' : ' ');
|
||||
} else {
|
||||
$prefix = $class ? $this->style('note', 'array:'.$class).' [' : '[';
|
||||
}
|
||||
|
||||
if ($cursor->softRefCount || 0 < $cursor->softRefHandle) {
|
||||
$prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), array('count' => $cursor->softRefCount));
|
||||
} elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) {
|
||||
$prefix .= $this->style('ref', '&'.$cursor->hardRefTo, array('count' => $cursor->hardRefCount));
|
||||
} elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) {
|
||||
$prefix = substr($prefix, 0, -1);
|
||||
}
|
||||
|
||||
$this->line .= $prefix;
|
||||
|
||||
if ($hasChild) {
|
||||
$this->dumpLine($cursor->depth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut)
|
||||
{
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
$this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : ''));
|
||||
$this->dumpLine($cursor->depth, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps an ellipsis for cut children.
|
||||
*
|
||||
* @param Cursor $cursor The Cursor position in the dump
|
||||
* @param bool $hasChild When the dump of the hash has child item
|
||||
* @param int $cut The number of items the hash has been cut by
|
||||
*/
|
||||
protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut)
|
||||
{
|
||||
if ($cut) {
|
||||
$this->line .= ' …';
|
||||
if (0 < $cut) {
|
||||
$this->line .= $cut;
|
||||
}
|
||||
if ($hasChild) {
|
||||
$this->dumpLine($cursor->depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps a key in a hash structure.
|
||||
*
|
||||
* @param Cursor $cursor The Cursor position in the dump
|
||||
*/
|
||||
protected function dumpKey(Cursor $cursor)
|
||||
{
|
||||
if (null !== $key = $cursor->hashKey) {
|
||||
if ($cursor->hashKeyIsBinary) {
|
||||
$key = $this->utf8Encode($key);
|
||||
}
|
||||
$attr = array('binary' => $cursor->hashKeyIsBinary);
|
||||
$bin = $cursor->hashKeyIsBinary ? 'b' : '';
|
||||
$style = 'key';
|
||||
switch ($cursor->hashType) {
|
||||
default:
|
||||
case Cursor::HASH_INDEXED:
|
||||
$style = 'index';
|
||||
case Cursor::HASH_ASSOC:
|
||||
if (is_int($key)) {
|
||||
$this->line .= $this->style($style, $key).' => ';
|
||||
} else {
|
||||
$this->line .= $bin.'"'.$this->style($style, $key).'" => ';
|
||||
}
|
||||
break;
|
||||
|
||||
case Cursor::HASH_RESOURCE:
|
||||
$key = "\0~\0".$key;
|
||||
// No break;
|
||||
case Cursor::HASH_OBJECT:
|
||||
if (!isset($key[0]) || "\0" !== $key[0]) {
|
||||
$this->line .= '+'.$bin.$this->style('public', $key).': ';
|
||||
} elseif (0 < strpos($key, "\0", 1)) {
|
||||
$key = explode("\0", substr($key, 1), 2);
|
||||
|
||||
switch ($key[0]) {
|
||||
case '+': // User inserted keys
|
||||
$attr['dynamic'] = true;
|
||||
$this->line .= '+'.$bin.'"'.$this->style('public', $key[1], $attr).'": ';
|
||||
break 2;
|
||||
case '~':
|
||||
$style = 'meta';
|
||||
break;
|
||||
case '*':
|
||||
$style = 'protected';
|
||||
$bin = '#'.$bin;
|
||||
break;
|
||||
default:
|
||||
$attr['class'] = $key[0];
|
||||
$style = 'private';
|
||||
$bin = '-'.$bin;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->line .= $bin.$this->style($style, $key[1], $attr).': ';
|
||||
} else {
|
||||
// This case should not happen
|
||||
$this->line .= '-'.$bin.'"'.$this->style('private', $key, array('class' => '')).'": ';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($cursor->hardRefTo) {
|
||||
$this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), array('count' => $cursor->hardRefCount)).' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates a value with some style.
|
||||
*
|
||||
* @param string $style The type of style being applied
|
||||
* @param string $value The value being styled
|
||||
* @param array $attr Optional context information
|
||||
*
|
||||
* @return string The value with style decoration
|
||||
*/
|
||||
protected function style($style, $value, $attr = array())
|
||||
{
|
||||
if (null === $this->colors) {
|
||||
$this->colors = $this->supportsColors();
|
||||
}
|
||||
|
||||
$style = $this->styles[$style];
|
||||
|
||||
$map = static::$controlCharsMap;
|
||||
$startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : '';
|
||||
$endCchr = $this->colors ? "\033[m\033[{$style}m" : '';
|
||||
$value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) {
|
||||
$s = $startCchr;
|
||||
$c = $c[$i = 0];
|
||||
do {
|
||||
$s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', ord($c[$i]));
|
||||
} while (isset($c[++$i]));
|
||||
|
||||
return $s.$endCchr;
|
||||
}, $value, -1, $cchrCount);
|
||||
|
||||
if ($this->colors) {
|
||||
if ($cchrCount && "\033" === $value[0]) {
|
||||
$value = substr($value, strlen($startCchr));
|
||||
} else {
|
||||
$value = "\033[{$style}m".$value;
|
||||
}
|
||||
if ($cchrCount && $endCchr === substr($value, -strlen($endCchr))) {
|
||||
$value = substr($value, 0, -strlen($endCchr));
|
||||
} else {
|
||||
$value .= "\033[{$this->styles['default']}m";
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool Tells if the current output stream supports ANSI colors or not
|
||||
*/
|
||||
protected function supportsColors()
|
||||
{
|
||||
if ($this->outputStream !== static::$defaultOutput) {
|
||||
return @(is_resource($this->outputStream) && function_exists('posix_isatty') && posix_isatty($this->outputStream));
|
||||
}
|
||||
if (null !== static::$defaultColors) {
|
||||
return static::$defaultColors;
|
||||
}
|
||||
if (isset($_SERVER['argv'][1])) {
|
||||
$colors = $_SERVER['argv'];
|
||||
$i = count($colors);
|
||||
while (--$i > 0) {
|
||||
if (isset($colors[$i][5])) {
|
||||
switch ($colors[$i]) {
|
||||
case '--ansi':
|
||||
case '--color':
|
||||
case '--color=yes':
|
||||
case '--color=force':
|
||||
case '--color=always':
|
||||
return static::$defaultColors = true;
|
||||
|
||||
case '--no-ansi':
|
||||
case '--color=no':
|
||||
case '--color=none':
|
||||
case '--color=never':
|
||||
return static::$defaultColors = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
static::$defaultColors = @(
|
||||
'10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
|
||||
|| false !== getenv('ANSICON')
|
||||
|| 'ON' === getenv('ConEmuANSI')
|
||||
|| 'xterm' === getenv('TERM')
|
||||
);
|
||||
} elseif (function_exists('posix_isatty')) {
|
||||
$h = stream_get_meta_data($this->outputStream) + array('wrapper_type' => null);
|
||||
$h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'wb') : $this->outputStream;
|
||||
static::$defaultColors = @posix_isatty($h);
|
||||
} else {
|
||||
static::$defaultColors = false;
|
||||
}
|
||||
|
||||
return static::$defaultColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpLine($depth, $endOfValue = false)
|
||||
{
|
||||
if ($this->colors) {
|
||||
$this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line);
|
||||
}
|
||||
parent::dumpLine($depth);
|
||||
}
|
||||
}
|
29
developer/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php
vendored
Normal file
29
developer/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php
vendored
Normal file
@ -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\VarDumper\Dumper;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
|
||||
/**
|
||||
* DataDumperInterface for dumping Data objects.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
interface DataDumperInterface
|
||||
{
|
||||
/**
|
||||
* Dumps a Data object.
|
||||
*
|
||||
* @param Data $data A Data object
|
||||
*/
|
||||
public function dump(Data $data);
|
||||
}
|
445
developer/vendor/symfony/var-dumper/Dumper/HtmlDumper.php
vendored
Normal file
445
developer/vendor/symfony/var-dumper/Dumper/HtmlDumper.php
vendored
Normal file
@ -0,0 +1,445 @@
|
||||
<?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\VarDumper\Dumper;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Cursor;
|
||||
use Symfony\Component\VarDumper\Cloner\Data;
|
||||
|
||||
/**
|
||||
* HtmlDumper dumps variables as HTML.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class HtmlDumper extends CliDumper
|
||||
{
|
||||
public static $defaultOutput = 'php://output';
|
||||
|
||||
protected $dumpHeader;
|
||||
protected $dumpPrefix = '<pre class=sf-dump id=%s data-indent-pad="%s">';
|
||||
protected $dumpSuffix = '</pre><script>Sfdump("%s")</script>';
|
||||
protected $dumpId = 'sf-dump';
|
||||
protected $colors = true;
|
||||
protected $headerIsDumped = false;
|
||||
protected $lastDepth = -1;
|
||||
protected $styles = array(
|
||||
'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
|
||||
'num' => 'font-weight:bold; color:#1299DA',
|
||||
'const' => 'font-weight:bold',
|
||||
'str' => 'font-weight:bold; color:#56DB3A',
|
||||
'note' => 'color:#1299DA',
|
||||
'ref' => 'color:#A0A0A0',
|
||||
'public' => 'color:#FFFFFF',
|
||||
'protected' => 'color:#FFFFFF',
|
||||
'private' => 'color:#FFFFFF',
|
||||
'meta' => 'color:#B729D9',
|
||||
'key' => 'color:#56DB3A',
|
||||
'index' => 'color:#1299DA',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct($output = null, $charset = null)
|
||||
{
|
||||
AbstractDumper::__construct($output, $charset);
|
||||
$this->dumpId = 'sf-dump-'.mt_rand();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setStyles(array $styles)
|
||||
{
|
||||
$this->headerIsDumped = false;
|
||||
$this->styles = $styles + $this->styles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an HTML header that will be dumped once in the output stream.
|
||||
*
|
||||
* @param string $header An HTML string
|
||||
*/
|
||||
public function setDumpHeader($header)
|
||||
{
|
||||
$this->dumpHeader = $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an HTML prefix and suffix that will encapse every single dump.
|
||||
*
|
||||
* @param string $prefix The prepended HTML string
|
||||
* @param string $suffix The appended HTML string
|
||||
*/
|
||||
public function setDumpBoundaries($prefix, $suffix)
|
||||
{
|
||||
$this->dumpPrefix = $prefix;
|
||||
$this->dumpSuffix = $suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function dump(Data $data, $output = null)
|
||||
{
|
||||
parent::dump($data, $output);
|
||||
$this->dumpId = 'sf-dump-'.mt_rand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps the HTML header.
|
||||
*/
|
||||
protected function getDumpHeader()
|
||||
{
|
||||
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
|
||||
|
||||
if (null !== $this->dumpHeader) {
|
||||
return $this->dumpHeader;
|
||||
}
|
||||
|
||||
$line = <<<'EOHTML'
|
||||
<script>
|
||||
Sfdump = window.Sfdump || (function (doc) {
|
||||
|
||||
var refStyle = doc.createElement('style'),
|
||||
rxEsc = /([.*+?^${}()|\[\]\/\\])/g,
|
||||
idRx = /\bsf-dump-\d+-ref[012]\w+\b/,
|
||||
keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl',
|
||||
addEventListener = function (e, n, cb) {
|
||||
e.addEventListener(n, cb, false);
|
||||
};
|
||||
|
||||
(doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle);
|
||||
|
||||
if (!doc.addEventListener) {
|
||||
addEventListener = function (element, eventName, callback) {
|
||||
element.attachEvent('on' + eventName, function (e) {
|
||||
e.preventDefault = function () {e.returnValue = false;};
|
||||
e.target = e.srcElement;
|
||||
callback(e);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function toggle(a, recursive) {
|
||||
var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass;
|
||||
|
||||
if ('sf-dump-compact' == oldClass) {
|
||||
arrow = '▼';
|
||||
newClass = 'sf-dump-expanded';
|
||||
} else if ('sf-dump-expanded' == oldClass) {
|
||||
arrow = '▶';
|
||||
newClass = 'sf-dump-compact';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
a.lastChild.innerHTML = arrow;
|
||||
s.className = newClass;
|
||||
|
||||
if (recursive) {
|
||||
try {
|
||||
a = s.querySelectorAll('.'+oldClass);
|
||||
for (s = 0; s < a.length; ++s) {
|
||||
if (a[s].className !== newClass) {
|
||||
a[s].className = newClass;
|
||||
a[s].previousSibling.lastChild.innerHTML = arrow;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return function (root) {
|
||||
root = doc.getElementById(root);
|
||||
|
||||
function a(e, f) {
|
||||
addEventListener(root, e, function (e) {
|
||||
if ('A' == e.target.tagName) {
|
||||
f(e.target, e);
|
||||
} else if ('A' == e.target.parentNode.tagName) {
|
||||
f(e.target.parentNode, e);
|
||||
}
|
||||
});
|
||||
};
|
||||
function isCtrlKey(e) {
|
||||
return e.ctrlKey || e.metaKey;
|
||||
}
|
||||
addEventListener(root, 'mouseover', function (e) {
|
||||
if ('' != refStyle.innerHTML) {
|
||||
refStyle.innerHTML = '';
|
||||
}
|
||||
});
|
||||
a('mouseover', function (a) {
|
||||
if (a = idRx.exec(a.className)) {
|
||||
try {
|
||||
refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}';
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
a('click', function (a, e) {
|
||||
if (/\bsf-dump-toggle\b/.test(a.className)) {
|
||||
e.preventDefault();
|
||||
if (!toggle(a, isCtrlKey(e))) {
|
||||
var r = doc.getElementById(a.getAttribute('href').substr(1)),
|
||||
s = r.previousSibling,
|
||||
f = r.parentNode,
|
||||
t = a.parentNode;
|
||||
t.replaceChild(r, a);
|
||||
f.replaceChild(a, s);
|
||||
t.insertBefore(s, r);
|
||||
f = f.firstChild.nodeValue.match(indentRx);
|
||||
t = t.firstChild.nodeValue.match(indentRx);
|
||||
if (f && t && f[0] !== t[0]) {
|
||||
r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]);
|
||||
}
|
||||
if ('sf-dump-compact' == r.className) {
|
||||
toggle(s, isCtrlKey(e));
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.getSelection) {
|
||||
try {
|
||||
doc.getSelection().removeAllRanges();
|
||||
} catch (e) {
|
||||
doc.getSelection().empty();
|
||||
}
|
||||
} else {
|
||||
doc.selection.empty();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'),
|
||||
elt = root.getElementsByTagName('A'),
|
||||
len = elt.length,
|
||||
i = 0,
|
||||
t = [];
|
||||
|
||||
while (i < len) t.push(elt[i++]);
|
||||
|
||||
elt = root.getElementsByTagName('SAMP');
|
||||
len = elt.length;
|
||||
i = 0;
|
||||
|
||||
while (i < len) t.push(elt[i++]);
|
||||
|
||||
root = t;
|
||||
len = t.length;
|
||||
i = t = 0;
|
||||
|
||||
while (i < len) {
|
||||
elt = root[i];
|
||||
if ("SAMP" == elt.tagName) {
|
||||
elt.className = "sf-dump-expanded";
|
||||
a = elt.previousSibling || {};
|
||||
if ('A' != a.tagName) {
|
||||
a = doc.createElement('A');
|
||||
a.className = 'sf-dump-ref';
|
||||
elt.parentNode.insertBefore(a, elt);
|
||||
} else {
|
||||
a.innerHTML += ' ';
|
||||
}
|
||||
a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children';
|
||||
a.innerHTML += '<span>▼</span>';
|
||||
a.className += ' sf-dump-toggle';
|
||||
if ('sf-dump' != elt.parentNode.className) {
|
||||
toggle(a);
|
||||
}
|
||||
} else if ("sf-dump-ref" == elt.className && (a = elt.getAttribute('href'))) {
|
||||
a = a.substr(1);
|
||||
elt.className += ' '+a;
|
||||
|
||||
if (/[\[{]$/.test(elt.previousSibling.nodeValue)) {
|
||||
a = a != elt.nextSibling.id && doc.getElementById(a);
|
||||
try {
|
||||
t = a.nextSibling;
|
||||
elt.appendChild(a);
|
||||
t.parentNode.insertBefore(a, t);
|
||||
if (/^[@#]/.test(elt.innerHTML)) {
|
||||
elt.innerHTML += ' <span>▶</span>';
|
||||
} else {
|
||||
elt.innerHTML = '<span>▶</span>';
|
||||
elt.className = 'sf-dump-ref';
|
||||
}
|
||||
elt.className += ' sf-dump-toggle';
|
||||
} catch (e) {
|
||||
if ('&' == elt.innerHTML.charAt(0)) {
|
||||
elt.innerHTML = '…';
|
||||
elt.className = 'sf-dump-ref';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
};
|
||||
|
||||
})(document);
|
||||
</script>
|
||||
<style>
|
||||
pre.sf-dump {
|
||||
display: block;
|
||||
white-space: pre;
|
||||
padding: 5px;
|
||||
}
|
||||
pre.sf-dump span {
|
||||
display: inline;
|
||||
}
|
||||
pre.sf-dump .sf-dump-compact {
|
||||
display: none;
|
||||
}
|
||||
pre.sf-dump abbr {
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
cursor: help;
|
||||
}
|
||||
pre.sf-dump a {
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
outline: none;
|
||||
}
|
||||
EOHTML;
|
||||
|
||||
foreach ($this->styles as $class => $style) {
|
||||
$line .= 'pre.sf-dump'.('default' !== $class ? ' .sf-dump-'.$class : '').'{'.$style.'}';
|
||||
}
|
||||
|
||||
return $this->dumpHeader = preg_replace('/\s+/', ' ', $line).'</style>'.$this->dumpHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enterHash(Cursor $cursor, $type, $class, $hasChild)
|
||||
{
|
||||
parent::enterHash($cursor, $type, $class, false);
|
||||
|
||||
if ($hasChild) {
|
||||
if ($cursor->refIndex) {
|
||||
$r = Cursor::HASH_OBJECT !== $type ? 1 - (Cursor::HASH_RESOURCE !== $type) : 2;
|
||||
$r .= $r && 0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->refIndex;
|
||||
|
||||
$this->line .= sprintf('<samp id=%s-ref%s>', $this->dumpId, $r);
|
||||
} else {
|
||||
$this->line .= '<samp>';
|
||||
}
|
||||
$this->dumpLine($cursor->depth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut)
|
||||
{
|
||||
$this->dumpEllipsis($cursor, $hasChild, $cut);
|
||||
if ($hasChild) {
|
||||
$this->line .= '</samp>';
|
||||
}
|
||||
parent::leaveHash($cursor, $type, $class, $hasChild, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function style($style, $value, $attr = array())
|
||||
{
|
||||
if ('' === $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$v = esc($value);
|
||||
|
||||
if ('ref' === $style) {
|
||||
if (empty($attr['count'])) {
|
||||
return sprintf('<a class=sf-dump-ref>%s</a>', $v);
|
||||
}
|
||||
$r = ('#' !== $v[0] ? 1 - ('@' !== $v[0]) : 2).substr($value, 1);
|
||||
|
||||
return sprintf('<a class=sf-dump-ref href=#%s-ref%s title="%d occurrences">%s</a>', $this->dumpId, $r, 1 + $attr['count'], $v);
|
||||
}
|
||||
|
||||
if ('const' === $style && isset($attr['value'])) {
|
||||
$style .= sprintf(' title="%s"', esc(is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value'])));
|
||||
} elseif ('public' === $style) {
|
||||
$style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property');
|
||||
} elseif ('str' === $style && 1 < $attr['length']) {
|
||||
$style .= sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : '');
|
||||
} elseif ('note' === $style && false !== $c = strrpos($v, '\\')) {
|
||||
return sprintf('<abbr title="%s" class=sf-dump-%s>%s</abbr>', $v, $style, substr($v, $c + 1));
|
||||
} elseif ('protected' === $style) {
|
||||
$style .= ' title="Protected property"';
|
||||
} elseif ('private' === $style) {
|
||||
$style .= sprintf(' title="Private property defined in class: `%s`"', esc($attr['class']));
|
||||
}
|
||||
|
||||
$map = static::$controlCharsMap;
|
||||
$style = "<span class=sf-dump-{$style}>";
|
||||
$v = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $style) {
|
||||
$s = '</span>';
|
||||
$c = $c[$i = 0];
|
||||
do {
|
||||
$s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', ord($c[$i]));
|
||||
} while (isset($c[++$i]));
|
||||
|
||||
return $s.$style;
|
||||
}, $v, -1, $cchrCount);
|
||||
|
||||
if ($cchrCount && '<' === $v[0]) {
|
||||
$v = substr($v, 7);
|
||||
} else {
|
||||
$v = $style.$v;
|
||||
}
|
||||
if ($cchrCount && '>' === substr($v, -1)) {
|
||||
$v = substr($v, 0, -strlen($style));
|
||||
} else {
|
||||
$v .= '</span>';
|
||||
}
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function dumpLine($depth, $endOfValue = false)
|
||||
{
|
||||
if (-1 === $this->lastDepth) {
|
||||
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
|
||||
}
|
||||
if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) {
|
||||
$this->line = $this->getDumpHeader().$this->line;
|
||||
}
|
||||
|
||||
if (-1 === $depth) {
|
||||
$this->line .= sprintf($this->dumpSuffix, $this->dumpId);
|
||||
}
|
||||
$this->lastDepth = $depth;
|
||||
|
||||
$this->line = mb_convert_encoding($this->line, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
if (-1 === $depth) {
|
||||
AbstractDumper::dumpLine(0);
|
||||
}
|
||||
AbstractDumper::dumpLine($depth);
|
||||
}
|
||||
}
|
||||
|
||||
function esc($str)
|
||||
{
|
||||
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
Reference in New Issue
Block a user