forked from Wavyzz/dolibarr
Update of var_dumper package 3.0 -> 3.2
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\VarDumper\Caster;
|
||||
|
||||
use Symfony\Component\VarDumper\Cloner\Stub;
|
||||
|
||||
/**
|
||||
* Helper for filtering out properties in casters.
|
||||
*
|
||||
@@ -36,29 +38,39 @@ class Caster
|
||||
/**
|
||||
* Casts objects to arrays and adds the dynamic property prefix.
|
||||
*
|
||||
* @param object $obj The object to cast.
|
||||
* @param \ReflectionClass $reflector The class reflector to use for inspecting the object definition.
|
||||
* @param object $obj The object to cast
|
||||
* @param \ReflectionClass $reflector The class reflector to use for inspecting the object definition
|
||||
*
|
||||
* @return array The array-cast of the object, with prefixed dynamic properties.
|
||||
* @return array The array-cast of the object, with prefixed dynamic properties
|
||||
*/
|
||||
public static function castObject($obj, \ReflectionClass $reflector)
|
||||
{
|
||||
if ($reflector->hasMethod('__debugInfo')) {
|
||||
$a = $obj->__debugInfo();
|
||||
} elseif ($obj instanceof \Closure) {
|
||||
$a = array();
|
||||
} else {
|
||||
$a = (array) $obj;
|
||||
}
|
||||
if ($obj instanceof \__PHP_Incomplete_Class) {
|
||||
return $a;
|
||||
}
|
||||
|
||||
if ($a) {
|
||||
$combine = false;
|
||||
$p = array_keys($a);
|
||||
foreach ($p as $i => $k) {
|
||||
if (!isset($k[0]) || ("\0" !== $k[0] && !$reflector->hasProperty($k))) {
|
||||
if (isset($k[0]) ? "\0" !== $k[0] && !$reflector->hasProperty($k) : \PHP_VERSION_ID >= 70200) {
|
||||
$combine = true;
|
||||
$p[$i] = self::PREFIX_DYNAMIC.$k;
|
||||
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
|
||||
$combine = true;
|
||||
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");
|
||||
}
|
||||
}
|
||||
$a = array_combine($p, $a);
|
||||
if ($combine) {
|
||||
$a = array_combine($p, $a);
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
@@ -70,14 +82,17 @@ class Caster
|
||||
* By default, a single match in the $filter bit field filters properties out, following an "or" logic.
|
||||
* When EXCLUDE_STRICT is set, an "and" logic is applied: all bits must match for a property to be removed.
|
||||
*
|
||||
* @param array $a The array containing the properties to filter.
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out.
|
||||
* @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set.
|
||||
* @param array $a The array containing the properties to filter
|
||||
* @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out
|
||||
* @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set
|
||||
* @param int &$count Set to the number of removed properties
|
||||
*
|
||||
* @return array The filtered array
|
||||
*/
|
||||
public static function filter(array $a, $filter, array $listedProperties = array())
|
||||
public static function filter(array $a, $filter, array $listedProperties = array(), &$count = 0)
|
||||
{
|
||||
$count = 0;
|
||||
|
||||
foreach ($a as $k => $v) {
|
||||
$type = self::EXCLUDE_STRICT & $filter;
|
||||
|
||||
@@ -108,9 +123,20 @@ class Caster
|
||||
|
||||
if ((self::EXCLUDE_STRICT & $filter) ? $type === $filter : $type) {
|
||||
unset($a[$k]);
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, $isNested)
|
||||
{
|
||||
if (isset($a['__PHP_Incomplete_Class_Name'])) {
|
||||
$stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')';
|
||||
unset($a['__PHP_Incomplete_Class_Name']);
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user