Skip to content

Commit

Permalink
Update of var_dumper package 3.0 -> 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarcouiller committed Jul 29, 2021
1 parent 7836651 commit b013322
Show file tree
Hide file tree
Showing 51 changed files with 2,386 additions and 578 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"nnnick/chartjs" : "^2.9",
"stripe/stripe-php" : "6.43.1",
"maximebf/debugbar" : "1.15.1",
"symfony/var-dumper" : "3"
"symfony/var-dumper" : "3.2"
},
"require-dev" : {
"php-parallel-lint/php-parallel-lint" : "^0",
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 75 additions & 29 deletions htdocs/includes/symfony/var-dumper/Caster/AmqpCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,30 @@ public static function castConnection(\AMQPConnection $c, array $a, Stub $stub,
{
$prefix = Caster::PREFIX_VIRTUAL;

// BC layer in the ampq lib
$a += array(
$prefix.'is_connected' => $c->isConnected(),
);

// Recent version of the extension already expose private properties
if (isset($a["\x00AMQPConnection\x00login"])) {
return $a;
}

// BC layer in the amqp lib
if (method_exists($c, 'getReadTimeout')) {
$timeout = $c->getReadTimeout();
} else {
$timeout = $c->getTimeout();
}

$a += array(
$prefix.'isConnected' => $c->isConnected(),
$prefix.'is_connected' => $c->isConnected(),
$prefix.'login' => $c->getLogin(),
$prefix.'password' => $c->getPassword(),
$prefix.'host' => $c->getHost(),
$prefix.'port' => $c->getPort(),
$prefix.'vhost' => $c->getVhost(),
$prefix.'readTimeout' => $timeout,
$prefix.'port' => $c->getPort(),
$prefix.'read_timeout' => $timeout,
);

return $a;
Expand All @@ -73,11 +82,19 @@ public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNes
$prefix = Caster::PREFIX_VIRTUAL;

$a += array(
$prefix.'isConnected' => $c->isConnected(),
$prefix.'channelId' => $c->getChannelId(),
$prefix.'prefetchSize' => $c->getPrefetchSize(),
$prefix.'prefetchCount' => $c->getPrefetchCount(),
$prefix.'is_connected' => $c->isConnected(),
$prefix.'channel_id' => $c->getChannelId(),
);

// Recent version of the extension already expose private properties
if (isset($a["\x00AMQPChannel\x00connection"])) {
return $a;
}

$a += array(
$prefix.'connection' => $c->getConnection(),
$prefix.'prefetch_size' => $c->getPrefetchSize(),
$prefix.'prefetch_count' => $c->getPrefetchCount(),
);

return $a;
Expand All @@ -88,11 +105,19 @@ public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested)
$prefix = Caster::PREFIX_VIRTUAL;

$a += array(
$prefix.'name' => $c->getName(),
$prefix.'flags' => self::extractFlags($c->getFlags()),
$prefix.'arguments' => $c->getArguments(),
);

// Recent version of the extension already expose private properties
if (isset($a["\x00AMQPQueue\x00name"])) {
return $a;
}

$a += array(
$prefix.'connection' => $c->getConnection(),
$prefix.'channel' => $c->getChannel(),
$prefix.'name' => $c->getName(),
$prefix.'arguments' => $c->getArguments(),
);

return $a;
Expand All @@ -103,12 +128,24 @@ public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isN
$prefix = Caster::PREFIX_VIRTUAL;

$a += array(
$prefix.'name' => $c->getName(),
$prefix.'flags' => self::extractFlags($c->getFlags()),
$prefix.'type' => isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType(),
$prefix.'arguments' => $c->getArguments(),
$prefix.'channel' => $c->getChannel(),
);

$type = isset(self::$exchangeTypes[$c->getType()]) ? new ConstStub(self::$exchangeTypes[$c->getType()], $c->getType()) : $c->getType();

// Recent version of the extension already expose private properties
if (isset($a["\x00AMQPExchange\x00name"])) {
$a["\x00AMQPExchange\x00type"] = $type;

return $a;
}

$a += array(
$prefix.'connection' => $c->getConnection(),
$prefix.'channel' => $c->getChannel(),
$prefix.'name' => $c->getName(),
$prefix.'type' => $type,
$prefix.'arguments' => $c->getArguments(),
);

return $a;
Expand All @@ -118,28 +155,37 @@ public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isN
{
$prefix = Caster::PREFIX_VIRTUAL;

$deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode());

// Recent version of the extension already expose private properties
if (isset($a["\x00AMQPEnvelope\x00body"])) {
$a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode;

return $a;
}

if (!($filter & Caster::EXCLUDE_VERBOSE)) {
$a += array($prefix.'body' => $c->getBody());
}

$a += array(
$prefix.'routingKey' => $c->getRoutingKey(),
$prefix.'deliveryTag' => $c->getDeliveryTag(),
$prefix.'deliveryMode' => new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()),
$prefix.'exchangeName' => $c->getExchangeName(),
$prefix.'isRedelivery' => $c->isRedelivery(),
$prefix.'contentType' => $c->getContentType(),
$prefix.'contentEncoding' => $c->getContentEncoding(),
$prefix.'type' => $c->getType(),
$prefix.'timestamp' => $c->getTimestamp(),
$prefix.'delivery_tag' => $c->getDeliveryTag(),
$prefix.'is_redelivery' => $c->isRedelivery(),
$prefix.'exchange_name' => $c->getExchangeName(),
$prefix.'routing_key' => $c->getRoutingKey(),
$prefix.'content_type' => $c->getContentType(),
$prefix.'content_encoding' => $c->getContentEncoding(),
$prefix.'headers' => $c->getHeaders(),
$prefix.'delivery_mode' => $deliveryMode,
$prefix.'priority' => $c->getPriority(),
$prefix.'correlation_id' => $c->getCorrelationId(),
$prefix.'reply_to' => $c->getReplyTo(),
$prefix.'expiration' => $c->getExpiration(),
$prefix.'userId' => $c->getUserId(),
$prefix.'appId' => $c->getAppId(),
$prefix.'messageId' => $c->getMessageId(),
$prefix.'replyTo' => $c->getReplyTo(),
$prefix.'correlationId' => $c->getCorrelationId(),
$prefix.'headers' => $c->getHeaders(),
$prefix.'message_id' => $c->getMessageId(),
$prefix.'timestamp' => $c->getTimeStamp(),
$prefix.'type' => $c->getType(),
$prefix.'user_id' => $c->getUserId(),
$prefix.'app_id' => $c->getAppId(),
);

return $a;
Expand Down
80 changes: 80 additions & 0 deletions htdocs/includes/symfony/var-dumper/Caster/ArgsStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* 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;

/**
* Represents a list of function arguments.
*
* @author Nicolas Grekas <[email protected]>
*/
class ArgsStub extends EnumStub
{
private static $parameters = array();

public function __construct(array $args, $function, $class)
{
list($variadic, $params) = self::getParameters($function, $class);

$values = array();
foreach ($args as $k => $v) {
$values[$k] = !is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v;
}
if (null === $params) {
parent::__construct($values, false);

return;
}
if (count($values) < count($params)) {
$params = array_slice($params, 0, count($values));
} elseif (count($values) > count($params)) {
$values[] = new EnumStub(array_splice($values, count($params)), false);
$params[] = $variadic;
}
if (array('...') === $params) {
$this->dumpKeys = false;
$this->value = $values[0]->value;
} else {
$this->value = array_combine($params, $values);
}
}

private static function getParameters($function, $class)
{
if (isset(self::$parameters[$k = $class.'::'.$function])) {
return self::$parameters[$k];
}

try {
$r = null !== $class ? new \ReflectionMethod($class, $function) : new \ReflectionFunction($function);
} catch (\ReflectionException $e) {
return array(null, null);
}

$variadic = '...';
$params = array();
foreach ($r->getParameters() as $v) {
$k = '$'.$v->name;
if ($v->isPassedByReference()) {
$k = '&'.$k;
}
if (method_exists($v, 'isVariadic') && $v->isVariadic()) {
$variadic .= $k;
} else {
$params[] = $k;
}
}

return self::$parameters[$k] = array($variadic, $params);
}
}
44 changes: 35 additions & 9 deletions htdocs/includes/symfony/var-dumper/Caster/Caster.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\VarDumper\Caster;

use Symfony\Component\VarDumper\Cloner\Stub;

/**
* Helper for filtering out properties in casters.
*
Expand All @@ -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;
Expand All @@ -70,14 +82,17 @@ public static function castObject($obj, \ReflectionClass $reflector)
* 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;

Expand Down Expand Up @@ -108,9 +123,20 @@ public static function filter(array $a, $filter, array $listedProperties = array

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;
}
}
Loading

0 comments on commit b013322

Please sign in to comment.