Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[VarDumper] Improve dump of AMQP* Object #21557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2017

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Feb 7, 2017

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:


screenshot4

screenshot5

@stof
Copy link
Member

stof commented Feb 7, 2017

shouldn't we rather avoid all the useless info instead of overwriting the existing ones ?

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Feb 7, 2017
@lyrixx
Copy link
Member Author

lyrixx commented Feb 8, 2017

shouldn't we rather avoid all the useless info instead of overwriting the existing ones ?

The things is: it's hard to know when property X or property Y has been added in the extension. So If we want to avoid overwriting, we should check for each property if it has been defined before.

WDYT?

@stof
Copy link
Member

stof commented Feb 8, 2017

Well, you are switching the prefix globally anyway, which implies that they all changed together.

@lyrixx
Copy link
Member Author

lyrixx commented Feb 8, 2017

Indeed. But anyway $array += [] does not overwrite the initial value. So IMHO, it's not an issue. I just specifically, overwrite some properties, to enchance the display.

But just to be sure I understand, you propose something like that:

        // Recent version of the extension already expose internal properties
        if (isset($a["\x00AMQPConnection\x00login"])) {
            $a += [
                Caster::PREFIX_VIRTUAL.'isConnected' => $c->isConnected(),
            ];

            return $a;
        }

        $prefix = Caster::PREFIX_VIRTUAL;

        // 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.'login' => $c->getLogin(),
            $prefix.'password' => $c->getPassword(),
            $prefix.'host' => $c->getHost(),
            $prefix.'vhost' => $c->getVhost(),
            $prefix.'port' => $c->getPort(),
            $prefix.'read_timeout' => $timeout,
        );

        return $a;

@lyrixx
Copy link
Member Author

lyrixx commented Feb 8, 2017

@stof I updated my PR according to your comments.

The release of https://github.com/pdezwart/php-amqp/ 1.7.0alpha1
changed internally the handlings of AMQP* object. So now when dumping
using var_dump(), many information are availables. So many information
are displayed twice. This commit fixes this issue and keeps displaying basic
information for older version of the lib.

Reference:

* https://pecl.php.net/package-info.php?package=amqp&version=1.7.0alpha1
* php-amqp/php-amqp@314afbc (and next commits)
@stof
Copy link
Member

stof commented Feb 8, 2017

👍

Btw, don't we need to update some tests ?

@lyrixx
Copy link
Member Author

lyrixx commented Feb 8, 2017

Btw, don't we need to update some tests ?

This part is not tested... :/

@nicolas-grekas
Copy link
Member

Thank you @lyrixx.

@nicolas-grekas nicolas-grekas merged commit c553352 into symfony:2.8 Feb 11, 2017
nicolas-grekas added a commit that referenced this pull request Feb 11, 2017
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
* php-amqp/php-amqp@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
@nicolas-grekas nicolas-grekas deleted the caster-amqp branch February 11, 2017 11:33
@fabpot fabpot mentioned this pull request Feb 17, 2017
@fabpot fabpot mentioned this pull request Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants