bug #21557 [VarDumper] Improve dump of AMQP* Object (lyrixx)
This PR was merged into the 2.8 branch.
Discussion
----------
[VarDumper] Improve dump of AMQP* Object
| Q | A
| ------------- | ---
| Branch? | 2.8
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
---
The release of https://github.com/pdezwart/php-amqp/ 1.7.0alpha1
changed internally the handling of AMQP* object. So now when dumping
using var_dump(), many information are available. So many information
are displayed twice. This commit fixes this issue and keeps displaying basic
information for older versions of the lib.
Reference:
* https://pecl.php.net/package-info.php?package=amqp&version=1.7.0alpha1
* https://github.com/pdezwart/php-amqp/commit/314afbc (and next commits)
---
![screenshot4](https://cloud.githubusercontent.com/assets/408368/22700884/53ad5f68-ed5c-11e6-986b-bfdf91640060.png)
![screenshot5](https://cloud.githubusercontent.com/assets/408368/22700890/580353c4-ed5c-11e6-8fc8-c101115b7001.png)
Commits
-------
c553352
[VarDumper] Improve dump of AMQP* Object
This commit is contained in:
commit
f6744d64d9
@ -48,6 +48,15 @@ class AmqpCaster
|
|||||||
{
|
{
|
||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
|
|
||||||
|
$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
|
// BC layer in the amqp lib
|
||||||
if (method_exists($c, 'getReadTimeout')) {
|
if (method_exists($c, 'getReadTimeout')) {
|
||||||
$timeout = $c->getReadTimeout();
|
$timeout = $c->getReadTimeout();
|
||||||
@ -56,13 +65,13 @@ class AmqpCaster
|
|||||||
}
|
}
|
||||||
|
|
||||||
$a += array(
|
$a += array(
|
||||||
$prefix.'isConnected' => $c->isConnected(),
|
$prefix.'is_connected' => $c->isConnected(),
|
||||||
$prefix.'login' => $c->getLogin(),
|
$prefix.'login' => $c->getLogin(),
|
||||||
$prefix.'password' => $c->getPassword(),
|
$prefix.'password' => $c->getPassword(),
|
||||||
$prefix.'host' => $c->getHost(),
|
$prefix.'host' => $c->getHost(),
|
||||||
$prefix.'port' => $c->getPort(),
|
|
||||||
$prefix.'vhost' => $c->getVhost(),
|
$prefix.'vhost' => $c->getVhost(),
|
||||||
$prefix.'readTimeout' => $timeout,
|
$prefix.'port' => $c->getPort(),
|
||||||
|
$prefix.'read_timeout' => $timeout,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
@ -73,11 +82,19 @@ class AmqpCaster
|
|||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
|
|
||||||
$a += array(
|
$a += array(
|
||||||
$prefix.'isConnected' => $c->isConnected(),
|
$prefix.'is_connected' => $c->isConnected(),
|
||||||
$prefix.'channelId' => $c->getChannelId(),
|
$prefix.'channel_id' => $c->getChannelId(),
|
||||||
$prefix.'prefetchSize' => $c->getPrefetchSize(),
|
);
|
||||||
$prefix.'prefetchCount' => $c->getPrefetchCount(),
|
|
||||||
|
// Recent version of the extension already expose private properties
|
||||||
|
if (isset($a["\x00AMQPChannel\x00connection"])) {
|
||||||
|
return $a;
|
||||||
|
}
|
||||||
|
|
||||||
|
$a += array(
|
||||||
$prefix.'connection' => $c->getConnection(),
|
$prefix.'connection' => $c->getConnection(),
|
||||||
|
$prefix.'prefetch_size' => $c->getPrefetchSize(),
|
||||||
|
$prefix.'prefetch_count' => $c->getPrefetchCount(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
@ -88,11 +105,19 @@ class AmqpCaster
|
|||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
|
|
||||||
$a += array(
|
$a += array(
|
||||||
$prefix.'name' => $c->getName(),
|
|
||||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
$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.'connection' => $c->getConnection(),
|
||||||
$prefix.'channel' => $c->getChannel(),
|
$prefix.'channel' => $c->getChannel(),
|
||||||
|
$prefix.'name' => $c->getName(),
|
||||||
|
$prefix.'arguments' => $c->getArguments(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
@ -103,12 +128,24 @@ class AmqpCaster
|
|||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$prefix = Caster::PREFIX_VIRTUAL;
|
||||||
|
|
||||||
$a += array(
|
$a += array(
|
||||||
$prefix.'name' => $c->getName(),
|
|
||||||
$prefix.'flags' => self::extractFlags($c->getFlags()),
|
$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.'connection' => $c->getConnection(),
|
||||||
|
$prefix.'channel' => $c->getChannel(),
|
||||||
|
$prefix.'name' => $c->getName(),
|
||||||
|
$prefix.'type' => $type,
|
||||||
|
$prefix.'arguments' => $c->getArguments(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
@ -118,28 +155,37 @@ class AmqpCaster
|
|||||||
{
|
{
|
||||||
$prefix = Caster::PREFIX_VIRTUAL;
|
$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)) {
|
if (!($filter & Caster::EXCLUDE_VERBOSE)) {
|
||||||
$a += array($prefix.'body' => $c->getBody());
|
$a += array($prefix.'body' => $c->getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
$a += array(
|
$a += array(
|
||||||
$prefix.'routingKey' => $c->getRoutingKey(),
|
$prefix.'delivery_tag' => $c->getDeliveryTag(),
|
||||||
$prefix.'deliveryTag' => $c->getDeliveryTag(),
|
$prefix.'is_redelivery' => $c->isRedelivery(),
|
||||||
$prefix.'deliveryMode' => new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()),
|
$prefix.'exchange_name' => $c->getExchangeName(),
|
||||||
$prefix.'exchangeName' => $c->getExchangeName(),
|
$prefix.'routing_key' => $c->getRoutingKey(),
|
||||||
$prefix.'isRedelivery' => $c->isRedelivery(),
|
$prefix.'content_type' => $c->getContentType(),
|
||||||
$prefix.'contentType' => $c->getContentType(),
|
$prefix.'content_encoding' => $c->getContentEncoding(),
|
||||||
$prefix.'contentEncoding' => $c->getContentEncoding(),
|
|
||||||
$prefix.'type' => $c->getType(),
|
|
||||||
$prefix.'timestamp' => $c->getTimeStamp(),
|
|
||||||
$prefix.'priority' => $c->getPriority(),
|
|
||||||
$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.'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.'message_id' => $c->getMessageId(),
|
||||||
|
$prefix.'timestamp' => $c->getTimeStamp(),
|
||||||
|
$prefix.'type' => $c->getType(),
|
||||||
|
$prefix.'user_id' => $c->getUserId(),
|
||||||
|
$prefix.'app_id' => $c->getAppId(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $a;
|
return $a;
|
||||||
|
Reference in New Issue
Block a user