composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -1,6 +1,11 @@
CHANGELOG
=========
4.2.0
-----
* support selecting the format to use by setting the environment variable `VAR_DUMPER_FORMAT` to `html` or `cli`
4.1.0
-----

View file

@ -11,6 +11,8 @@
namespace Symfony\Component\VarDumper\Caster;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* Represents a PHP class identifier.
*
@ -19,19 +21,13 @@ namespace Symfony\Component\VarDumper\Caster;
class ClassStub extends ConstStub
{
/**
* @param string A PHP identifier, e.g. a class, method, interface, etc. name
* @param callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier
* @param string $identifier A PHP identifier, e.g. a class, method, interface, etc. name
* @param callable $callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier
*/
public function __construct(string $identifier, $callable = null)
{
$this->value = $identifier;
if (0 < $i = strrpos($identifier, '\\')) {
$this->attr['ellipsis'] = \strlen($identifier) - $i;
$this->attr['ellipsis-type'] = 'class';
$this->attr['ellipsis-tail'] = 1;
}
try {
if (null !== $callable) {
if ($callable instanceof \Closure) {
@ -58,8 +54,31 @@ class ClassStub extends ConstStub
$r = new \ReflectionClass($r[0]);
}
}
if (false !== strpos($identifier, "class@anonymous\0")) {
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $identifier);
}
if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) {
$s = ReflectionCaster::castFunctionAbstract($r, array(), new Stub(), true);
$s = ReflectionCaster::getSignature($s);
if ('()' === substr($identifier, -2)) {
$this->value = substr_replace($identifier, $s, -2);
} else {
$this->value .= $s;
}
}
} catch (\ReflectionException $e) {
return;
} finally {
if (0 < $i = strrpos($this->value, '\\')) {
$this->attr['ellipsis'] = \strlen($this->value) - $i;
$this->attr['ellipsis-type'] = 'class';
$this->attr['ellipsis-tail'] = 1;
}
}
if ($f = $r->getFileName()) {
@ -75,9 +94,9 @@ class ClassStub extends ConstStub
}
if (!\is_array($callable)) {
$callable = new static($callable);
$callable = new static($callable, $callable);
} elseif (\is_string($callable[0])) {
$callable[0] = new static($callable[0]);
$callable[0] = new static($callable[0], $callable);
} else {
$callable[1] = new static($callable[1], $callable);
}

View file

@ -71,7 +71,9 @@ class ExceptionCaster
if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) {
$b = (array) $a[$xPrefix.'previous'];
self::traceUnshift($b[$xPrefix.'trace'], \get_class($a[$xPrefix.'previous']), $b[$prefix.'file'], $b[$prefix.'line']);
$class = \get_class($a[$xPrefix.'previous']);
$class = 'c' === $class[0] && 0 === strpos($class, "class@anonymous\0") ? get_parent_class($class).'@anonymous' : $class;
self::traceUnshift($b[$xPrefix.'trace'], $class, $b[$prefix.'file'], $b[$prefix.'line']);
$a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value));
}
@ -279,6 +281,12 @@ class ExceptionCaster
}
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
return \class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $a[Caster::PREFIX_PROTECTED.'message']);
}
if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) {
$a[Caster::PREFIX_PROTECTED.'file'] = new LinkStub($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']);
}

View file

@ -0,0 +1,171 @@
<?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\Caster;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* @author Nicolas Grekas <p@tchwork.com>
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
*/
class IntlCaster
{
public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, $isNested)
{
$a += array(
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
);
return self::castError($c, $a);
}
public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, $isNested, $filter = 0)
{
$a += array(
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
);
if ($filter & Caster::EXCLUDE_VERBOSE) {
$stub->cut += 3;
return self::castError($c, $a);
}
$a += array(
Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub(
array(
'PARSE_INT_ONLY' => $c->getAttribute(\NumberFormatter::PARSE_INT_ONLY),
'GROUPING_USED' => $c->getAttribute(\NumberFormatter::GROUPING_USED),
'DECIMAL_ALWAYS_SHOWN' => $c->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN),
'MAX_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS),
'MIN_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS),
'INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::INTEGER_DIGITS),
'MAX_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS),
'MIN_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS),
'FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::FRACTION_DIGITS),
'MULTIPLIER' => $c->getAttribute(\NumberFormatter::MULTIPLIER),
'GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::GROUPING_SIZE),
'ROUNDING_MODE' => $c->getAttribute(\NumberFormatter::ROUNDING_MODE),
'ROUNDING_INCREMENT' => $c->getAttribute(\NumberFormatter::ROUNDING_INCREMENT),
'FORMAT_WIDTH' => $c->getAttribute(\NumberFormatter::FORMAT_WIDTH),
'PADDING_POSITION' => $c->getAttribute(\NumberFormatter::PADDING_POSITION),
'SECONDARY_GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE),
'SIGNIFICANT_DIGITS_USED' => $c->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED),
'MIN_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS),
'MAX_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS),
'LENIENT_PARSE' => $c->getAttribute(\NumberFormatter::LENIENT_PARSE),
)
),
Caster::PREFIX_VIRTUAL.'text_attributes' => new EnumStub(
array(
'POSITIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX),
'POSITIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX),
'NEGATIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX),
'NEGATIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX),
'PADDING_CHARACTER' => $c->getTextAttribute(\NumberFormatter::PADDING_CHARACTER),
'CURRENCY_CODE' => $c->getTextAttribute(\NumberFormatter::CURRENCY_CODE),
'DEFAULT_RULESET' => $c->getTextAttribute(\NumberFormatter::DEFAULT_RULESET),
'PUBLIC_RULESETS' => $c->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS),
)
),
Caster::PREFIX_VIRTUAL.'symbols' => new EnumStub(
array(
'DECIMAL_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL),
'GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL),
'PATTERN_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL),
'PERCENT_SYMBOL' => $c->getSymbol(\NumberFormatter::PERCENT_SYMBOL),
'ZERO_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL),
'DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::DIGIT_SYMBOL),
'MINUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL),
'PLUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL),
'CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::CURRENCY_SYMBOL),
'INTL_CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL),
'MONETARY_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL),
'EXPONENTIAL_SYMBOL' => $c->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL),
'PERMILL_SYMBOL' => $c->getSymbol(\NumberFormatter::PERMILL_SYMBOL),
'PAD_ESCAPE_SYMBOL' => $c->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL),
'INFINITY_SYMBOL' => $c->getSymbol(\NumberFormatter::INFINITY_SYMBOL),
'NAN_SYMBOL' => $c->getSymbol(\NumberFormatter::NAN_SYMBOL),
'SIGNIFICANT_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL),
'MONETARY_GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL),
)
),
);
return self::castError($c, $a);
}
public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, $isNested)
{
$a += array(
Caster::PREFIX_VIRTUAL.'display_name' => $c->getDisplayName(),
Caster::PREFIX_VIRTUAL.'id' => $c->getID(),
Caster::PREFIX_VIRTUAL.'raw_offset' => $c->getRawOffset(),
);
if ($c->useDaylightTime()) {
$a += array(
Caster::PREFIX_VIRTUAL.'dst_savings' => $c->getDSTSavings(),
);
}
return self::castError($c, $a);
}
public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, $isNested, $filter = 0)
{
$a += array(
Caster::PREFIX_VIRTUAL.'type' => $c->getType(),
Caster::PREFIX_VIRTUAL.'first_day_of_week' => $c->getFirstDayOfWeek(),
Caster::PREFIX_VIRTUAL.'minimal_days_in_first_week' => $c->getMinimalDaysInFirstWeek(),
Caster::PREFIX_VIRTUAL.'repeated_wall_time_option' => $c->getRepeatedWallTimeOption(),
Caster::PREFIX_VIRTUAL.'skipped_wall_time_option' => $c->getSkippedWallTimeOption(),
Caster::PREFIX_VIRTUAL.'time' => $c->getTime(),
Caster::PREFIX_VIRTUAL.'type' => $c->getType(),
Caster::PREFIX_VIRTUAL.'in_daylight_time' => $c->inDaylightTime(),
Caster::PREFIX_VIRTUAL.'is_lenient' => $c->isLenient(),
Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(),
);
return self::castError($c, $a);
}
public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, $isNested, $filter = 0)
{
$a += array(
Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(),
Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(),
Caster::PREFIX_VIRTUAL.'calendar' => $c->getCalendar(),
Caster::PREFIX_VIRTUAL.'time_zone_id' => $c->getTimeZoneId(),
Caster::PREFIX_VIRTUAL.'time_type' => $c->getTimeType(),
Caster::PREFIX_VIRTUAL.'date_type' => $c->getDateType(),
Caster::PREFIX_VIRTUAL.'calendar_object' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getCalendarObject()) : $c->getCalendarObject(),
Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(),
);
return self::castError($c, $a);
}
private static function castError($c, array $a): array
{
if ($errorCode = $c->getErrorCode()) {
$a += array(
Caster::PREFIX_VIRTUAL.'error_code' => $errorCode,
Caster::PREFIX_VIRTUAL.'error_message' => $c->getErrorMessage(),
);
}
return $a;
}
}

View file

@ -0,0 +1,79 @@
<?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\Caster;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
*/
class MemcachedCaster
{
private static $optionConstants;
private static $defaultOptions;
public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNested)
{
$a += array(
Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(),
Caster::PREFIX_VIRTUAL.'options' => new EnumStub(
self::getNonDefaultOptions($c)
),
);
return $a;
}
private static function getNonDefaultOptions(\Memcached $c)
{
self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions();
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
$nonDefaultOptions = array();
foreach (self::$optionConstants as $constantKey => $value) {
if (self::$defaultOptions[$constantKey] !== $option = $c->getOption($value)) {
$nonDefaultOptions[$constantKey] = $option;
}
}
return $nonDefaultOptions;
}
private static function discoverDefaultOptions()
{
$defaultMemcached = new \Memcached();
$defaultMemcached->addServer('127.0.0.1', 11211);
$defaultOptions = array();
self::$optionConstants = self::$optionConstants ?? self::getOptionConstants();
foreach (self::$optionConstants as $constantKey => $value) {
$defaultOptions[$constantKey] = $defaultMemcached->getOption($value);
}
return $defaultOptions;
}
private static function getOptionConstants()
{
$reflectedMemcached = new \ReflectionClass(\Memcached::class);
$optionConstants = array();
foreach ($reflectedMemcached->getConstants() as $constantKey => $value) {
if (0 === strpos($constantKey, 'OPT_')) {
$optionConstants[$constantKey] = $value;
}
}
return $optionConstants;
}
}

View file

@ -0,0 +1,31 @@
<?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\Caster;
use ProxyManager\Proxy\ProxyInterface;
use Symfony\Component\VarDumper\Cloner\Stub;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class ProxyManagerCaster
{
public static function castProxy(ProxyInterface $c, array $a, Stub $stub, $isNested)
{
if ($parent = \get_parent_class($c)) {
$stub->class .= ' - '.$parent;
}
$stub->class .= '@proxy';
return $a;
}
}

View file

@ -26,6 +26,24 @@ class RedisCaster
2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY
);
private static $mode = array(
\Redis::ATOMIC => 'ATOMIC',
\Redis::MULTI => 'MULTI',
\Redis::PIPELINE => 'PIPELINE',
);
private static $compression = array(
0 => 'NONE', // Redis::COMPRESSION_NONE
1 => 'LZF', // Redis::COMPRESSION_LZF
);
private static $failover = array(
\RedisCluster::FAILOVER_NONE => 'NONE',
\RedisCluster::FAILOVER_ERROR => 'ERROR',
\RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE',
\RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES',
);
public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
@ -36,23 +54,19 @@ class RedisCaster
);
}
$ser = $c->getOption(\Redis::OPT_SERIALIZER);
$retry = \defined('Redis::OPT_SCAN') ? $c->getOption(\Redis::OPT_SCAN) : 0;
$mode = $c->getMode();
return $a + array(
$prefix.'isConnected' => $connected,
$prefix.'host' => $c->getHost(),
$prefix.'port' => $c->getPort(),
$prefix.'auth' => $c->getAuth(),
$prefix.'mode' => isset(self::$mode[$mode]) ? new ConstStub(self::$mode[$mode], $mode) : $mode,
$prefix.'dbNum' => $c->getDbNum(),
$prefix.'timeout' => $c->getTimeout(),
$prefix.'lastError' => $c->getLastError(),
$prefix.'persistentId' => $c->getPersistentID(),
$prefix.'options' => new EnumStub(array(
'READ_TIMEOUT' => $c->getOption(\Redis::OPT_READ_TIMEOUT),
'SERIALIZER' => isset(self::$serializer[$ser]) ? new ConstStub(self::$serializer[$ser], $ser) : $ser,
'PREFIX' => $c->getOption(\Redis::OPT_PREFIX),
'SCAN' => new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry),
)),
$prefix.'options' => self::getRedisOptions($c),
);
}
@ -63,6 +77,74 @@ class RedisCaster
return $a + array(
$prefix.'hosts' => $c->_hosts(),
$prefix.'function' => ClassStub::wrapCallable($c->_function()),
$prefix.'lastError' => $c->getLastError(),
$prefix.'options' => self::getRedisOptions($c),
);
}
public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, $isNested)
{
$prefix = Caster::PREFIX_VIRTUAL;
$failover = $c->getOption(\RedisCluster::OPT_SLAVE_FAILOVER);
$a += array(
$prefix.'_masters' => $c->_masters(),
$prefix.'_redir' => $c->_redir(),
$prefix.'mode' => new ConstStub($c->getMode() ? 'MULTI' : 'ATOMIC', $c->getMode()),
$prefix.'lastError' => $c->getLastError(),
$prefix.'options' => self::getRedisOptions($c, array(
'SLAVE_FAILOVER' => isset(self::$failover[$failover]) ? new ConstStub(self::$failover[$failover], $failover) : $failover,
)),
);
return $a;
}
/**
* @param \Redis|\RedisArray|\RedisCluster $redis
*/
private static function getRedisOptions($redis, array $options = array()): EnumStub
{
$serializer = $redis->getOption(\Redis::OPT_SERIALIZER);
if (\is_array($serializer)) {
foreach ($serializer as &$v) {
if (isset(self::$serializer[$v])) {
$v = new ConstStub(self::$serializer[$v], $v);
}
}
} elseif (isset(self::$serializer[$serializer])) {
$serializer = new ConstStub(self::$serializer[$serializer], $serializer);
}
$compression = \defined('Redis::OPT_COMPRESSION') ? $redis->getOption(\Redis::OPT_COMPRESSION) : 0;
if (\is_array($compression)) {
foreach ($compression as &$v) {
if (isset(self::$compression[$v])) {
$v = new ConstStub(self::$compression[$v], $v);
}
}
} elseif (isset(self::$compression[$compression])) {
$compression = new ConstStub(self::$compression[$compression], $compression);
}
$retry = \defined('Redis::OPT_SCAN') ? $redis->getOption(\Redis::OPT_SCAN) : 0;
if (\is_array($retry)) {
foreach ($retry as &$v) {
$v = new ConstStub($v ? 'RETRY' : 'NORETRY', $v);
}
} else {
$retry = new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry);
}
$options += array(
'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : 0,
'READ_TIMEOUT' => $redis->getOption(\Redis::OPT_READ_TIMEOUT),
'COMPRESSION' => $compression,
'SERIALIZER' => $serializer,
'PREFIX' => $redis->getOption(\Redis::OPT_PREFIX),
'SCAN' => $retry,
);
return new EnumStub($options);
}
}

View file

@ -38,6 +38,20 @@ class ReflectionCaster
$a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter);
if (false === strpos($c->name, '{closure}')) {
$stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name;
unset($a[$prefix.'class']);
}
unset($a[$prefix.'extra']);
$stub->class .= self::getSignature($a);
if ($filter & Caster::EXCLUDE_VERBOSE) {
$stub->cut += ($c->getFileName() ? 2 : 0) + \count($a);
return array();
}
if (isset($a[$prefix.'parameters'])) {
foreach ($a[$prefix.'parameters']->value as &$v) {
$param = $v;
@ -51,14 +65,11 @@ class ReflectionCaster
}
}
if (!($filter & Caster::EXCLUDE_VERBOSE) && $f = $c->getFileName()) {
if ($f = $c->getFileName()) {
$a[$prefix.'file'] = new LinkStub($f, $c->getStartLine());
$a[$prefix.'line'] = $c->getStartLine().' to '.$c->getEndLine();
}
$prefix = Caster::PREFIX_DYNAMIC;
unset($a['name'], $a[$prefix.'this'], $a[$prefix.'parameter'], $a[Caster::PREFIX_VIRTUAL.'extra']);
return $a;
}
@ -294,6 +305,52 @@ class ReflectionCaster
return $a;
}
public static function getSignature(array $a)
{
$prefix = Caster::PREFIX_VIRTUAL;
$signature = '';
if (isset($a[$prefix.'parameters'])) {
foreach ($a[$prefix.'parameters']->value as $k => $param) {
$signature .= ', ';
if ($type = $param->getType()) {
if (!$param->isOptional() && $param->allowsNull()) {
$signature .= '?';
}
$signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' ';
}
$signature .= $k;
if (!$param->isDefaultValueAvailable()) {
continue;
}
$v = $param->getDefaultValue();
$signature .= ' = ';
if ($param->isDefaultValueConstant()) {
$signature .= substr(strrchr('\\'.$param->getDefaultValueConstantName(), '\\'), 1);
} elseif (null === $v) {
$signature .= 'null';
} elseif (\is_array($v)) {
$signature .= $v ? '[…'.\count($v).']' : '[]';
} elseif (\is_string($v)) {
$signature .= 10 > \strlen($v) && false === strpos($v, '\\') ? "'{$v}'" : "'…".\strlen($v)."'";
} elseif (\is_bool($v)) {
$signature .= $v ? 'true' : 'false';
} else {
$signature .= $v;
}
}
}
$signature = (empty($a[$prefix.'returnsReference']) ? '' : '&').'('.substr($signature, 2).')';
if (isset($a[$prefix.'returnType'])) {
$signature .= ': '.substr(strrchr('\\'.$a[$prefix.'returnType'], '\\'), 1);
}
return $signature;
}
private static function addExtra(&$a, \Reflector $c)
{
$x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : array();

View file

@ -81,6 +81,7 @@ abstract class AbstractCloner implements ClonerInterface
'Symfony\Component\VarDumper\Caster\FrameStub' => array('Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'),
'Symfony\Component\Debug\Exception\SilencedErrorContext' => array('Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'),
'ProxyManager\Proxy\ProxyInterface' => array('Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'),
'PHPUnit_Framework_MockObject_MockObject' => array('Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'),
'Prophecy\Prophecy\ProphecySubjectInterface' => array('Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'),
'Mockery\MockInterface' => array('Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'),
@ -107,6 +108,7 @@ abstract class AbstractCloner implements ClonerInterface
'Redis' => array('Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'),
'RedisArray' => array('Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'),
'RedisCluster' => array('Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisCluster'),
'DateTimeInterface' => array('Symfony\Component\VarDumper\Caster\DateCaster', 'castDateTime'),
'DateInterval' => array('Symfony\Component\VarDumper\Caster\DateCaster', 'castInterval'),
@ -115,6 +117,14 @@ abstract class AbstractCloner implements ClonerInterface
'GMP' => array('Symfony\Component\VarDumper\Caster\GmpCaster', 'castGmp'),
'MessageFormatter' => array('Symfony\Component\VarDumper\Caster\IntlCaster', 'castMessageFormatter'),
'NumberFormatter' => array('Symfony\Component\VarDumper\Caster\IntlCaster', 'castNumberFormatter'),
'IntlTimeZone' => array('Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlTimeZone'),
'IntlCalendar' => array('Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlCalendar'),
'IntlDateFormatter' => array('Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlDateFormatter'),
'Memcached' => array('Symfony\Component\VarDumper\Caster\MemcachedCaster', 'castMemcached'),
':curl' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'),
':dba' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'),
':dba persistent' => array('Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'),
@ -218,7 +228,7 @@ abstract class AbstractCloner implements ClonerInterface
}
if ($this->prevErrorHandler) {
return \call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);
return ($this->prevErrorHandler)($type, $msg, $file, $line, $context);
}
return false;

View file

@ -115,9 +115,7 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
throw new \LogicException(sprintf('%s object holds non-iterable type "%s".', self::class, \gettype($value)));
}
foreach ($value as $k => $v) {
yield $k => $v;
}
yield from $value;
}
public function __get($key)

View file

@ -30,8 +30,8 @@ class VarCloner extends AbstractCloner
$queue = array(array($var)); // This breadth-first queue is the return value
$indexedArrays = array(); // Map of queue indexes that hold numerically indexed arrays
$hardRefs = array(); // Map of original zval ids to stub objects
$objRefs = array(); // Map of original object handles to their stub object couterpart
$resRefs = array(); // Map of original resource handles to their stub object couterpart
$objRefs = array(); // Map of original object handles to their stub object counterpart
$resRefs = array(); // Map of original resource handles to their stub object counterpart
$values = array(); // Map of stub objects' ids to original values
$maxItems = $this->maxItems;
$maxString = $this->maxString;

View file

@ -57,7 +57,7 @@ class HtmlDescriptor implements DumpDescriptorInterface
$sourceDescription = '';
if (isset($context['source'])) {
$source = $context['source'];
$projectDir = $source['project_dir'];
$projectDir = $source['project_dir'] ?? null;
$sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']);
if (isset($source['file_link'])) {
$sourceDescription = sprintf('<a href="%s">%s</a>', $source['file_link'], $sourceDescription);

View file

@ -164,7 +164,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 = '';
}

View file

@ -23,6 +23,41 @@ class HtmlDumper extends CliDumper
{
public static $defaultOutput = 'php://output';
protected static $themes = array(
'dark' => 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: break-all',
'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',
'ellipsis' => 'color:#FF8400',
'ns' => 'user-select:none;',
),
'light' => array(
'default' => 'background:none; color:#CC7832; 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: break-all',
'num' => 'font-weight:bold; color:#1299DA',
'const' => 'font-weight:bold',
'str' => 'font-weight:bold; color:#629755;',
'note' => 'color:#6897BB',
'ref' => 'color:#6E6E6E',
'public' => 'color:#262626',
'protected' => 'color:#262626',
'private' => 'color:#262626',
'meta' => 'color:#B729D9',
'key' => 'color:#789339',
'index' => 'color:#1299DA',
'ellipsis' => 'color:#CC7832',
'ns' => 'user-select:none;',
),
);
protected $dumpHeader;
protected $dumpPrefix = '<pre class=sf-dump id=%s data-indent-pad="%s">';
protected $dumpSuffix = '</pre><script>Sfdump(%s)</script>';
@ -30,21 +65,7 @@ class HtmlDumper extends CliDumper
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: break-all',
'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',
'ellipsis' => 'color:#FF8400',
);
protected $styles;
private $displayOptions = array(
'maxDepth' => 1,
@ -61,6 +82,7 @@ class HtmlDumper extends CliDumper
AbstractDumper::__construct($output, $charset, $flags);
$this->dumpId = 'sf-dump-'.mt_rand();
$this->displayOptions['fileLinkFormat'] = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
$this->styles = static::$themes['dark'] ?? self::$themes['dark'];
}
/**
@ -72,6 +94,15 @@ class HtmlDumper extends CliDumper
$this->styles = $styles + $this->styles;
}
public function setTheme(string $themeName)
{
if (!isset(static::$themes[$themeName])) {
throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class));
}
$this->setStyles(static::$themes[$themeName]);
}
/**
* Configures display options.
*
@ -473,6 +504,9 @@ return function (root, x) {
if (currentNode) {
reveal(currentNode);
highlight(root, currentNode, state.nodes);
if ('scrollIntoView' in currentNode) {
currentNode.scrollIntoView();
}
}
counter.textContent = (state.isEmpty() ? 0 : state.idx + 1) + ' of ' + state.count();
}
@ -837,9 +871,21 @@ EOHTML
}
$v = "<span class=sf-dump-{$style}>".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) {
$s = '<span class=sf-dump-default>';
$s = $b = '<span class="sf-dump-default';
$c = $c[$i = 0];
if ($ns = "\r" === $c[$i] || "\n" === $c[$i]) {
$s .= ' sf-dump-ns';
}
$s .= '">';
do {
if (("\r" === $c[$i] || "\n" === $c[$i]) !== $ns) {
$s .= '</span>'.$b;
if ($ns = !$ns) {
$s .= ' sf-dump-ns';
}
$s .= '">';
}
$s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', \ord($c[$i]));
} while (isset($c[++$i]));

View file

@ -1,4 +1,4 @@
Copyright (c) 2014-2018 Fabien Potencier
Copyright (c) 2014-2019 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -127,3 +127,4 @@ pre.sf-dump {
.dumped-tag > .sf-dump .sf-dump-ref { color: #6E6E6E; }
.dumped-tag > .sf-dump .sf-dump-ellipsis { color: #CC7832; max-width: 100em; }
.dumped-tag > .sf-dump .sf-dump-ellipsis-path { max-width: 5em; }
.dumped-tag > .sf-dump .sf-dump-ns { user-select: none; }

View file

@ -32,14 +32,12 @@ if (!function_exists('dump')) {
}
if (!function_exists('dd')) {
function dd($var, ...$moreVars)
function dd(...$vars)
{
VarDumper::dump($var);
foreach ($moreVars as $v) {
foreach ($vars as $v) {
VarDumper::dump($v);
}
exit(1);
die(1);
}
}

View file

@ -223,6 +223,23 @@ Exception {
#file: "%sExceptionCasterTest.php"
#line: 28
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);
}
public function testAnonymous()
{
$e = new \Exception(sprintf('Boo "%s" ba.', \get_class(new class('Foo') extends \Exception {
})));
$expectedDump = <<<'EODUMP'
Exception {
#message: "Boo "Exception@anonymous" ba."
#code: 0
#file: "%sExceptionCasterTest.php"
#line: %d
}
EODUMP;
$this->assertDumpMatchesFormat($expectedDump, $e, Caster::EXCLUDE_VERBOSE);

View file

@ -0,0 +1,299 @@
<?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\Tests\Caster;
use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
/**
* @requires extension intl
*/
class IntlCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testMessageFormatter()
{
$var = new \MessageFormatter('en', 'Hello {name}');
$expected = <<<EOTXT
MessageFormatter {
locale: "en"
pattern: "Hello {name}"
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastNumberFormatter()
{
$var = new \NumberFormatter('en', \NumberFormatter::DECIMAL);
$expectedLocale = $var->getLocale();
$expectedPattern = $var->getPattern();
$expectedAttribute1 = $var->getAttribute(\NumberFormatter::PARSE_INT_ONLY);
$expectedAttribute2 = $var->getAttribute(\NumberFormatter::GROUPING_USED);
$expectedAttribute3 = $var->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN);
$expectedAttribute4 = $var->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS);
$expectedAttribute5 = $var->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS);
$expectedAttribute6 = $var->getAttribute(\NumberFormatter::INTEGER_DIGITS);
$expectedAttribute7 = $var->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS);
$expectedAttribute8 = $var->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS);
$expectedAttribute9 = $var->getAttribute(\NumberFormatter::FRACTION_DIGITS);
$expectedAttribute10 = $var->getAttribute(\NumberFormatter::MULTIPLIER);
$expectedAttribute11 = $var->getAttribute(\NumberFormatter::GROUPING_SIZE);
$expectedAttribute12 = $var->getAttribute(\NumberFormatter::ROUNDING_MODE);
$expectedAttribute13 = number_format($var->getAttribute(\NumberFormatter::ROUNDING_INCREMENT), 1);
$expectedAttribute14 = $var->getAttribute(\NumberFormatter::FORMAT_WIDTH);
$expectedAttribute15 = $var->getAttribute(\NumberFormatter::PADDING_POSITION);
$expectedAttribute16 = $var->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE);
$expectedAttribute17 = $var->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED);
$expectedAttribute18 = $var->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS);
$expectedAttribute19 = $var->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS);
$expectedAttribute20 = $var->getAttribute(\NumberFormatter::LENIENT_PARSE);
$expectedTextAttribute1 = $var->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX);
$expectedTextAttribute2 = $var->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX);
$expectedTextAttribute3 = $var->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX);
$expectedTextAttribute4 = $var->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX);
$expectedTextAttribute5 = $var->getTextAttribute(\NumberFormatter::PADDING_CHARACTER);
$expectedTextAttribute6 = $var->getTextAttribute(\NumberFormatter::CURRENCY_CODE);
$expectedTextAttribute7 = $var->getTextAttribute(\NumberFormatter::DEFAULT_RULESET) ? 'true' : 'false';
$expectedTextAttribute8 = $var->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS) ? 'true' : 'false';
$expectedSymbol1 = $var->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$expectedSymbol2 = $var->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
$expectedSymbol3 = $var->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL);
$expectedSymbol4 = $var->getSymbol(\NumberFormatter::PERCENT_SYMBOL);
$expectedSymbol5 = $var->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL);
$expectedSymbol6 = $var->getSymbol(\NumberFormatter::DIGIT_SYMBOL);
$expectedSymbol7 = $var->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL);
$expectedSymbol8 = $var->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL);
$expectedSymbol9 = $var->getSymbol(\NumberFormatter::CURRENCY_SYMBOL);
$expectedSymbol10 = $var->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL);
$expectedSymbol11 = $var->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL);
$expectedSymbol12 = $var->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL);
$expectedSymbol13 = $var->getSymbol(\NumberFormatter::PERMILL_SYMBOL);
$expectedSymbol14 = $var->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL);
$expectedSymbol15 = $var->getSymbol(\NumberFormatter::INFINITY_SYMBOL);
$expectedSymbol16 = $var->getSymbol(\NumberFormatter::NAN_SYMBOL);
$expectedSymbol17 = $var->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL);
$expectedSymbol18 = $var->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL);
$expected = <<<EOTXT
NumberFormatter {
locale: "$expectedLocale"
pattern: "$expectedPattern"
attributes: {
PARSE_INT_ONLY: $expectedAttribute1
GROUPING_USED: $expectedAttribute2
DECIMAL_ALWAYS_SHOWN: $expectedAttribute3
MAX_INTEGER_DIGITS: $expectedAttribute4
MIN_INTEGER_DIGITS: $expectedAttribute5
INTEGER_DIGITS: $expectedAttribute6
MAX_FRACTION_DIGITS: $expectedAttribute7
MIN_FRACTION_DIGITS: $expectedAttribute8
FRACTION_DIGITS: $expectedAttribute9
MULTIPLIER: $expectedAttribute10
GROUPING_SIZE: $expectedAttribute11
ROUNDING_MODE: $expectedAttribute12
ROUNDING_INCREMENT: $expectedAttribute13
FORMAT_WIDTH: $expectedAttribute14
PADDING_POSITION: $expectedAttribute15
SECONDARY_GROUPING_SIZE: $expectedAttribute16
SIGNIFICANT_DIGITS_USED: $expectedAttribute17
MIN_SIGNIFICANT_DIGITS: $expectedAttribute18
MAX_SIGNIFICANT_DIGITS: $expectedAttribute19
LENIENT_PARSE: $expectedAttribute20
}
text_attributes: {
POSITIVE_PREFIX: "$expectedTextAttribute1"
POSITIVE_SUFFIX: "$expectedTextAttribute2"
NEGATIVE_PREFIX: "$expectedTextAttribute3"
NEGATIVE_SUFFIX: "$expectedTextAttribute4"
PADDING_CHARACTER: "$expectedTextAttribute5"
CURRENCY_CODE: "$expectedTextAttribute6"
DEFAULT_RULESET: $expectedTextAttribute7
PUBLIC_RULESETS: $expectedTextAttribute8
}
symbols: {
DECIMAL_SEPARATOR_SYMBOL: "$expectedSymbol1"
GROUPING_SEPARATOR_SYMBOL: "$expectedSymbol2"
PATTERN_SEPARATOR_SYMBOL: "$expectedSymbol3"
PERCENT_SYMBOL: "$expectedSymbol4"
ZERO_DIGIT_SYMBOL: "$expectedSymbol5"
DIGIT_SYMBOL: "$expectedSymbol6"
MINUS_SIGN_SYMBOL: "$expectedSymbol7"
PLUS_SIGN_SYMBOL: "$expectedSymbol8"
CURRENCY_SYMBOL: "$expectedSymbol9"
INTL_CURRENCY_SYMBOL: "$expectedSymbol10"
MONETARY_SEPARATOR_SYMBOL: "$expectedSymbol11"
EXPONENTIAL_SYMBOL: "$expectedSymbol12"
PERMILL_SYMBOL: "$expectedSymbol13"
PAD_ESCAPE_SYMBOL: "$expectedSymbol14"
INFINITY_SYMBOL: "$expectedSymbol15"
NAN_SYMBOL: "$expectedSymbol16"
SIGNIFICANT_DIGIT_SYMBOL: "$expectedSymbol17"
MONETARY_GROUPING_SEPARATOR_SYMBOL: "$expectedSymbol18"
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlTimeZoneWithDST()
{
$var = \IntlTimeZone::createTimeZone('America/Los_Angeles');
$expectedDisplayName = $var->getDisplayName();
$expectedDSTSavings = $var->getDSTSavings();
$expectedID = $var->getID();
$expectedRawOffset = $var->getRawOffset();
$expected = <<<EOTXT
IntlTimeZone {
display_name: "$expectedDisplayName"
id: "$expectedID"
raw_offset: $expectedRawOffset
dst_savings: $expectedDSTSavings
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlTimeZoneWithoutDST()
{
$var = \IntlTimeZone::createTimeZone('Asia/Bangkok');
$expectedDisplayName = $var->getDisplayName();
$expectedID = $var->getID();
$expectedRawOffset = $var->getRawOffset();
$expected = <<<EOTXT
IntlTimeZone {
display_name: "$expectedDisplayName"
id: "$expectedID"
raw_offset: $expectedRawOffset
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastIntlCalendar()
{
$var = \IntlCalendar::createInstance('America/Los_Angeles', 'en');
$expectedType = $var->getType();
$expectedFirstDayOfWeek = $var->getFirstDayOfWeek();
$expectedMinimalDaysInFirstWeek = $var->getMinimalDaysInFirstWeek();
$expectedRepeatedWallTimeOption = $var->getRepeatedWallTimeOption();
$expectedSkippedWallTimeOption = $var->getSkippedWallTimeOption();
$expectedTime = $var->getTime().'.0';
$expectedInDaylightTime = $var->inDaylightTime() ? 'true' : 'false';
$expectedIsLenient = $var->isLenient() ? 'true' : 'false';
$expectedTimeZone = $var->getTimeZone();
$expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
$expectedTimeZoneID = $expectedTimeZone->getID();
$expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
$expectedTimeZoneDSTSavings = $expectedTimeZone->getDSTSavings();
$expected = <<<EOTXT
IntlGregorianCalendar {
type: "$expectedType"
first_day_of_week: $expectedFirstDayOfWeek
minimal_days_in_first_week: $expectedMinimalDaysInFirstWeek
repeated_wall_time_option: $expectedRepeatedWallTimeOption
skipped_wall_time_option: $expectedSkippedWallTimeOption
time: $expectedTime
in_daylight_time: $expectedInDaylightTime
is_lenient: $expectedIsLenient
time_zone: IntlTimeZone {
display_name: "$expectedTimeZoneDisplayName"
id: "$expectedTimeZoneID"
raw_offset: $expectedTimeZoneRawOffset
dst_savings: $expectedTimeZoneDSTSavings
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastDateFormatter()
{
$var = new \IntlDateFormatter('en', \IntlDateFormatter::TRADITIONAL, \IntlDateFormatter::TRADITIONAL);
$expectedLocale = $var->getLocale();
$expectedPattern = $var->getPattern();
$expectedCalendar = $var->getCalendar();
$expectedTimeZoneId = $var->getTimeZoneId();
$expectedTimeType = $var->getTimeType();
$expectedDateType = $var->getDateType();
$expectedCalendarObject = $var->getCalendarObject();
$expectedCalendarObjectType = $expectedCalendarObject->getType();
$expectedCalendarObjectFirstDayOfWeek = $expectedCalendarObject->getFirstDayOfWeek();
$expectedCalendarObjectMinimalDaysInFirstWeek = $expectedCalendarObject->getMinimalDaysInFirstWeek();
$expectedCalendarObjectRepeatedWallTimeOption = $expectedCalendarObject->getRepeatedWallTimeOption();
$expectedCalendarObjectSkippedWallTimeOption = $expectedCalendarObject->getSkippedWallTimeOption();
$expectedCalendarObjectTime = $expectedCalendarObject->getTime().'.0';
$expectedCalendarObjectInDaylightTime = $expectedCalendarObject->inDaylightTime() ? 'true' : 'false';
$expectedCalendarObjectIsLenient = $expectedCalendarObject->isLenient() ? 'true' : 'false';
$expectedCalendarObjectTimeZone = $expectedCalendarObject->getTimeZone();
$expectedCalendarObjectTimeZoneDisplayName = $expectedCalendarObjectTimeZone->getDisplayName();
$expectedCalendarObjectTimeZoneID = $expectedCalendarObjectTimeZone->getID();
$expectedCalendarObjectTimeZoneRawOffset = $expectedCalendarObjectTimeZone->getRawOffset();
$expectedCalendarObjectTimeZoneDSTSavings = $expectedCalendarObjectTimeZone->getDSTSavings();
$expectedTimeZone = $var->getTimeZone();
$expectedTimeZoneDisplayName = $expectedTimeZone->getDisplayName();
$expectedTimeZoneID = $expectedTimeZone->getID();
$expectedTimeZoneRawOffset = $expectedTimeZone->getRawOffset();
$expectedTimeZoneDSTSavings = $expectedTimeZone->getDSTSavings();
$expected = <<<EOTXT
IntlDateFormatter {
locale: "$expectedLocale"
pattern: "$expectedPattern"
calendar: $expectedCalendar
time_zone_id: "$expectedTimeZoneId"
time_type: $expectedTimeType
date_type: $expectedDateType
calendar_object: IntlGregorianCalendar {
type: "$expectedCalendarObjectType"
first_day_of_week: $expectedCalendarObjectFirstDayOfWeek
minimal_days_in_first_week: $expectedCalendarObjectMinimalDaysInFirstWeek
repeated_wall_time_option: $expectedCalendarObjectRepeatedWallTimeOption
skipped_wall_time_option: $expectedCalendarObjectSkippedWallTimeOption
time: $expectedCalendarObjectTime
in_daylight_time: $expectedCalendarObjectInDaylightTime
is_lenient: $expectedCalendarObjectIsLenient
time_zone: IntlTimeZone {
display_name: "$expectedCalendarObjectTimeZoneDisplayName"
id: "$expectedCalendarObjectTimeZoneID"
raw_offset: $expectedCalendarObjectTimeZoneRawOffset
dst_savings: $expectedCalendarObjectTimeZoneDSTSavings
}
}
time_zone: IntlTimeZone {
display_name: "$expectedTimeZoneDisplayName"
id: "$expectedTimeZoneID"
raw_offset: $expectedTimeZoneRawOffset
dst_savings: $expectedTimeZoneDSTSavings
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
}

View file

@ -0,0 +1,93 @@
<?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\Tests\Caster;
use PHPUnit\Framework\TestCase;
use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
/**
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
*/
class MemcachedCasterTest extends TestCase
{
use VarDumperTestTrait;
public function testCastMemcachedWithDefaultOptions()
{
if (!class_exists('Memcached')) {
$this->markTestSkipped('Memcached not available');
}
$var = new \Memcached();
$var->addServer('127.0.0.1', 11211);
$var->addServer('127.0.0.2', 11212);
$expected = <<<EOTXT
Memcached {
servers: array:2 [
0 => array:3 [
"host" => "127.0.0.1"
"port" => 11211
"type" => "TCP"
]
1 => array:3 [
"host" => "127.0.0.2"
"port" => 11212
"type" => "TCP"
]
]
options: {}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
public function testCastMemcachedWithCustomOptions()
{
if (!class_exists('Memcached')) {
$this->markTestSkipped('Memcached not available');
}
$var = new \Memcached();
$var->addServer('127.0.0.1', 11211);
$var->addServer('127.0.0.2', 11212);
// set a subset of non default options to test boolean, string and integer output
$var->setOption(\Memcached::OPT_COMPRESSION, false);
$var->setOption(\Memcached::OPT_PREFIX_KEY, 'pre');
$var->setOption(\Memcached::OPT_DISTRIBUTION, \Memcached::DISTRIBUTION_CONSISTENT);
$expected = <<<'EOTXT'
Memcached {
servers: array:2 [
0 => array:3 [
"host" => "127.0.0.1"
"port" => 11211
"type" => "TCP"
]
1 => array:3 [
"host" => "127.0.0.2"
"port" => 11212
"type" => "TCP"
]
]
options: {
OPT_COMPRESSION: false
OPT_PREFIX_KEY: "pre"
OPT_DISTRIBUTION: 1
}
}
EOTXT;
$this->assertDumpEquals($expected, $var);
}
}

View file

@ -49,11 +49,15 @@ Redis {%A
host: "127.0.0.1"
port: 6379
auth: null
mode: ATOMIC
dbNum: 0
timeout: 0.0
lastError: null
persistentId: null
options: {
TCP_KEEPALIVE: 0
READ_TIMEOUT: 0.0
COMPRESSION: NONE
SERIALIZER: NONE
PREFIX: null
SCAN: NORETRY

View file

@ -68,14 +68,14 @@ EOTXT
$var = function ($x) use ($a, &$b) {};
$this->assertDumpMatchesFormat(
<<<EOTXT
Closure {
<<<'EOTXT'
Closure($x) {
%Aparameters: {
\$x: {}
$x: {}
}
use: {
\$a: 123
\$b: & 123
$a: 123
$b: & 123
}
file: "%sReflectionCasterTest.php"
line: "68 to 68"
@ -85,18 +85,39 @@ EOTXT
);
}
public function testFromCallableClosureCaster()
{
if (\defined('HHVM_VERSION_ID')) {
$this->markTestSkipped('Not for HHVM.');
}
$var = array(
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
(new \ReflectionMethod(__CLASS__, 'tearDownAfterClass'))->getClosure(),
);
$this->assertDumpMatchesFormat(
<<<EOTXT
array:2 [
0 => Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest::testFromCallableClosureCaster() {
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { }
file: "%sReflectionCasterTest.php"
line: "%d to %d"
}
1 => %sTestCase::tearDownAfterClass() {
file: "%sTestCase.php"
line: "%d to %d"
}
]
EOTXT
, $var
);
}
public function testClosureCasterExcludingVerbosity()
{
$var = function () {};
$var = function &($a = 5) {};
$expectedDump = <<<EOTXT
Closure {
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { }
}
EOTXT;
$this->assertDumpEquals($expectedDump, $var, Caster::EXCLUDE_VERBOSE);
$this->assertDumpEquals('Closure&($a = 5) { …6}', $var, Caster::EXCLUDE_VERBOSE);
}
public function testReflectionParameter()
@ -140,7 +161,7 @@ EOTXT
$this->assertDumpMatchesFormat(
<<<EOTXT
Closure {
Closure(): int {
returnType: "int"
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { }

View file

@ -35,7 +35,7 @@ SplFileInfo {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@ -85,7 +85,7 @@ SplFileObject {
aTime: %s-%s-%d %d:%d:%d
mTime: %s-%s-%d %d:%d:%d
cTime: %s-%s-%d %d:%d:%d
inode: %d
inode: %i
size: %d
perms: 0%d
owner: %d
@ -105,7 +105,7 @@ SplFileObject {
maxLineLen: 0
fstat: array:26 [
"dev" => %d
"ino" => %d
"ino" => %i
"nlink" => %d
"rdev" => 0
"blksize" => %i

View file

@ -141,7 +141,7 @@ EODUMP;
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10" rel="noopener noreferrer"><span class=sf-dump-str title="5 characters">hello</span></a>"
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10" rel="noopener noreferrer"><span class=sf-dump-str title="39 characters">hello(?stdClass $a, stdClass $b = null)</span></a>"
</samp>]
</bar>
EODUMP;
@ -185,6 +185,27 @@ EODUMP;
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:5" rel="noopener noreferrer"><span class=sf-dump-str title="5 characters">hello</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}
public function testClassStubWithAnonymousClass()
{
$var = array(new ClassStub(\get_class(new class() extends \Exception {
})));
$cloner = new VarCloner();
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($var), true, array('fileLinkFormat' => '%f:%l'));
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp>
<span class=sf-dump-index>0</span> => "<a href="%sStubCasterTest.php:195" rel="noopener noreferrer"><span class=sf-dump-str title="19 characters">Exception@anonymous</span></a>"
</samp>]
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);

View file

@ -0,0 +1,134 @@
<?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\Tests\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor;
use Symfony\Component\VarDumper\Dumper\CliDumper;
class CliDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$descriptor = new CliDescriptor(new CliDumper(function ($s) {
return $s;
}));
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), str_replace(PHP_EOL, "\n", trim($output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
Received from client #1
-----------------------
-------- ---------------------------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file /Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- ---------------------------------------------------------------------------------------------------
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
Received from client #1
-----------------------
-------- --------------------------------------------------------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
source CliDescriptorTest.php on line 30
file src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php
-------- --------------------------------------------------------------------------------
Open source in your IDE/browser:
phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
$ bin/phpunit
-------------
------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
------ ---------------------------------
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
GET http://localhost/foo
------------------------
------------ ---------------------------------
date Fri, 14 Dec 2018 16:17:48 +0000
controller "FooController.php"
------------ ---------------------------------
TXT
);
}
}

View file

@ -0,0 +1,195 @@
<?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\Tests\Command\Descriptor;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\VarDumper\Cloner\Data;
use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor;
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
class HtmlDescriptorTest extends TestCase
{
private static $timezone;
public static function setUpBeforeClass()
{
self::$timezone = date_default_timezone_get();
date_default_timezone_set('UTC');
}
public static function tearDownAfterClass()
{
date_default_timezone_set(self::$timezone);
}
public function testItOutputsStylesAndScriptsOnFirstDescribeCall()
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output');
$descriptor->describe($output, new Data(array(array(123))), array('timestamp' => 1544804268.3668), 1);
$this->assertStringNotMatchesFormat('<style>%A</style><script>%A</script>%A', $output->fetch(), 'styles & scripts are output only once');
}
/**
* @dataProvider provideContext
*/
public function testDescribe(array $context, string $expectedOutput)
{
$output = new BufferedOutput();
$dumper = $this->createMock(HtmlDumper::class);
$dumper->method('dump')->willReturn('[DUMPED]');
$descriptor = new HtmlDescriptor($dumper);
$descriptor->describe($output, new Data(array(array(123))), $context + array('timestamp' => 1544804268.3668), 1);
$this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@<style>.*</style><script>.*</script>@s', '', $output->fetch())));
}
public function provideContext()
{
yield 'source' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'line' => 30,
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
CliDescriptorTest.php on line 30
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'source full' => array(
array(
'source' => array(
'name' => 'CliDescriptorTest.php',
'project_dir' => 'src/Symfony/',
'line' => 30,
'file_relative' => 'src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file' => '/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php',
'file_link' => 'phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30',
),
),
<<<TXT
<article data-dedup-id="%s">
<header>
<div class="row">
<h2 class="col">-</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">project dir</span>src/Symfony/</li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
<a href="phpstorm://open?file=/Users/ogi/symfony/src/Symfony/Component/VarDumper/Tests/Command/Descriptor/CliDescriptorTest.php&line=30">CliDescriptorTest.php on line 30</a>
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'cli' => array(
array(
'cli' => array(
'identifier' => 'd8bece1c',
'command_line' => 'bin/phpunit',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>$ </code>bin/phpunit</h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
yield 'request' => array(
array(
'request' => array(
'identifier' => 'd8bece1c',
'controller' => new Data(array(array('FooController.php'))),
'method' => 'GET',
'uri' => 'http://localhost/foo',
),
),
<<<TXT
<article data-dedup-id="d8bece1c">
<header>
<div class="row">
<h2 class="col"><code>GET</code> <a href="http://localhost/foo">http://localhost/foo</a></h2>
<time class="col text-small" title="2018-12-14T16:17:48+00:00" datetime="2018-12-14T16:17:48+00:00">
Fri, 14 Dec 2018 16:17:48 +0000
</time>
</div>
<div class="row">
<ul class="tags">
<li><span class="badge">controller</span><span class='dumped-tag'>[DUMPED]</span></li>
</ul>
</div>
</header>
<section class="body">
<p class="text-small">
</p>
[DUMPED]
</section>
</article>
TXT
);
}
}

View file

@ -61,7 +61,10 @@ array:24 [
5 => -INF
6 => {$intMax}
"str" => "déjà\\n"
7 => b"é\\x00"
7 => b"""
é\\x00test\\t\\n
ing
"""
"[]" => []
"res" => stream resource {@{$res}
%A wrapper_type: "plainfile"
@ -75,7 +78,7 @@ array:24 [
+foo: "foo"
+"bar": "bar"
}
"closure" => Closure {#%d
"closure" => Closure(\$a, PDO &\$b = null) {#%d
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {#%d …}
parameters: {

View file

@ -63,8 +63,11 @@ class HtmlDumperTest extends TestCase
<span class=sf-dump-key>4</span> => <span class=sf-dump-num>INF</span>
<span class=sf-dump-key>5</span> => <span class=sf-dump-num>-INF</span>
<span class=sf-dump-key>6</span> => <span class=sf-dump-num>{$intMax}</span>
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;<span class=sf-dump-default>\\n</span></span>"
<span class=sf-dump-key>7</span> => b"<span class=sf-dump-str title="2 binary or non-UTF-8 characters">&%s;<span class=sf-dump-default>\\x00</span></span>"
"<span class=sf-dump-key>str</span>" => "<span class=sf-dump-str title="5 characters">d&%s;j&%s;<span class="sf-dump-default sf-dump-ns">\\n</span></span>"
<span class=sf-dump-key>7</span> => b"""
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">&eacute;<span class="sf-dump-default">\\x00</span>test<span class="sf-dump-default">\\t</span><span class="sf-dump-default sf-dump-ns">\\n</span></span>
<span class=sf-dump-str title="11 binary or non-UTF-8 characters">ing</span>
"""
"<span class=sf-dump-key>[]</span>" => []
"<span class=sf-dump-key>res</span>" => <span class=sf-dump-note>stream resource</span> <a class=sf-dump-ref>@{$res}</a><samp>
%A <span class=sf-dump-meta>wrapper_type</span>: "<span class=sf-dump-str title="9 characters">plainfile</span>"
@ -78,7 +81,7 @@ class HtmlDumperTest extends TestCase
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"
</samp>}
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure</span> {<a class=sf-dump-ref>#%d</a><samp>
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure(\$a, PDO &amp;\$b = null)</span> {<a class=sf-dump-ref>#%d</a><samp>
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class=sf-dump-ellipsis>\</span>HtmlDumperTest</span>"
<span class=sf-dump-meta>this</span>: <abbr title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest" class=sf-dump-note>HtmlDumperTest</abbr> {<a class=sf-dump-ref>#%d</a> &%s;}

View file

@ -7,5 +7,5 @@ interface FooInterface
/**
* Hello.
*/
public function foo();
public function foo(?\stdClass $a, \stdClass $b = null);
}

View file

@ -17,7 +17,7 @@ $g = fopen(__FILE__, 'r');
$var = array(
'number' => 1, null,
'const' => 1.1, true, false, NAN, INF, -INF, PHP_INT_MAX,
'str' => "déjà\n", "\xE9\x00",
'str' => "déjà\n", "\xE9\x00test\t\ning",
'[]' => array(),
'res' => $g,
'obj' => $foo,

View file

@ -29,13 +29,19 @@ class VarDumper
{
if (null === self::$handler) {
$cloner = new VarCloner();
$dumper = \in_array(\PHP_SAPI, array('cli', 'phpdbg'), true) ? new CliDumper() : new HtmlDumper();
if (isset($_SERVER['VAR_DUMPER_FORMAT'])) {
$dumper = 'html' === $_SERVER['VAR_DUMPER_FORMAT'] ? new HtmlDumper() : new CliDumper();
} else {
$dumper = \in_array(\PHP_SAPI, array('cli', 'phpdbg')) ? new CliDumper() : new HtmlDumper();
}
self::$handler = function ($var) use ($cloner, $dumper) {
$dumper->dump($cloner->cloneVar($var));
};
}
return \call_user_func(self::$handler, $var);
return (self::$handler)($var);
}
public static function setHandler(callable $callable = null)

View file

@ -22,6 +22,7 @@
},
"require-dev": {
"ext-iconv": "*",
"symfony/console": "~3.4|~4.0",
"symfony/process": "~3.4|~4.0",
"twig/twig": "~1.34|~2.4"
},
@ -47,7 +48,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
"dev-master": "4.2-dev"
}
}
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"