updated-packages
This commit is contained in:
@@ -21,10 +21,10 @@ use Symfony\Component\VarDumper\Cloner\DumperInterface;
|
||||
*/
|
||||
abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
{
|
||||
const DUMP_LIGHT_ARRAY = 1;
|
||||
const DUMP_STRING_LENGTH = 2;
|
||||
const DUMP_COMMA_SEPARATOR = 4;
|
||||
const DUMP_TRAILING_COMMA = 8;
|
||||
public const DUMP_LIGHT_ARRAY = 1;
|
||||
public const DUMP_STRING_LENGTH = 2;
|
||||
public const DUMP_COMMA_SEPARATOR = 4;
|
||||
public const DUMP_TRAILING_COMMA = 8;
|
||||
|
||||
public static $defaultOutput = 'php://output';
|
||||
|
||||
@@ -35,19 +35,18 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
protected $indentPad = ' ';
|
||||
protected $flags;
|
||||
|
||||
private $charset;
|
||||
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
|
||||
* @param string|null $charset The default character encoding to use for non-UTF8 strings
|
||||
* @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation
|
||||
*/
|
||||
public function __construct($output = null, string $charset = null, int $flags = 0)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
$this->setCharset($charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->decimalPoint = localeconv();
|
||||
$this->decimalPoint = $this->decimalPoint['decimal_point'];
|
||||
$this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8');
|
||||
$this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point'];
|
||||
$this->setOutput($output ?: static::$defaultOutput);
|
||||
if (!$output && \is_string(static::$defaultOutput)) {
|
||||
static::$defaultOutput = $this->outputStream;
|
||||
@@ -63,17 +62,17 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*/
|
||||
public function setOutput($output)
|
||||
{
|
||||
$prev = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
|
||||
$prev = $this->outputStream ?? $this->lineDumper;
|
||||
|
||||
if (\is_callable($output)) {
|
||||
$this->outputStream = null;
|
||||
$this->lineDumper = $output;
|
||||
} else {
|
||||
if (\is_string($output)) {
|
||||
$output = fopen($output, 'wb');
|
||||
$output = fopen($output, 'w');
|
||||
}
|
||||
$this->outputStream = $output;
|
||||
$this->lineDumper = array($this, 'echoLine');
|
||||
$this->lineDumper = [$this, 'echoLine'];
|
||||
}
|
||||
|
||||
return $prev;
|
||||
@@ -116,22 +115,20 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
/**
|
||||
* Dumps a Data object.
|
||||
*
|
||||
* @param Data $data A Data object
|
||||
* @param callable|resource|string|true|null $output A line dumper callable, an opened stream, an output path or true to return the dump
|
||||
*
|
||||
* @return string|null The dump as string when $output is true
|
||||
*/
|
||||
public function dump(Data $data, $output = null)
|
||||
{
|
||||
$this->decimalPoint = localeconv();
|
||||
$this->decimalPoint = $this->decimalPoint['decimal_point'];
|
||||
$this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point'];
|
||||
|
||||
if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(LC_NUMERIC, 0) : null) {
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) {
|
||||
setlocale(\LC_NUMERIC, 'C');
|
||||
}
|
||||
|
||||
if ($returnDump = true === $output) {
|
||||
$output = fopen('php://memory', 'r+b');
|
||||
$output = fopen('php://memory', 'r+');
|
||||
}
|
||||
if ($output) {
|
||||
$prevOutput = $this->setOutput($output);
|
||||
@@ -151,9 +148,11 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
$this->setOutput($prevOutput);
|
||||
}
|
||||
if ($locale) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
setlocale(\LC_NUMERIC, $locale);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +163,7 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
*/
|
||||
protected function dumpLine($depth)
|
||||
{
|
||||
\call_user_func($this->lineDumper, $this->line, $depth, $this->indentPad);
|
||||
($this->lineDumper)($this->line, $depth, $this->indentPad);
|
||||
$this->line = '';
|
||||
}
|
||||
|
||||
@@ -185,13 +184,13 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
/**
|
||||
* Converts a non-UTF-8 string to UTF-8.
|
||||
*
|
||||
* @param string $s The non-UTF-8 string to convert
|
||||
* @param string|null $s The non-UTF-8 string to convert
|
||||
*
|
||||
* @return string The string converted to UTF-8
|
||||
* @return string|null The string converted to UTF-8
|
||||
*/
|
||||
protected function utf8Encode($s)
|
||||
{
|
||||
if (preg_match('//u', $s)) {
|
||||
if (null === $s || preg_match('//u', $s)) {
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user