Skip to content

[VarDumper] VarCloner chokes on GMP numbers #25198

Closed
@fgm

Description

@fgm
Q A
Bug report? yes
Feature request? no
BC Break report? ?
RFC? no
Symfony version 3.3.13
PHP Version 7.1.11

When dumping data, the VarCloner incorrectly attempts to clone elements in the data tree in doClone() depending on their type, looping on this switch:

                // [...]
                switch (true) {
                    case empty($v):
                    case true === $v:
                    case \is_int($v):
                    case \is_float($v):
                        continue 2;
                // [...]

However, if $v is a GMP number, this switch throws a recoverable fatal error, because the switch evaluation tries to evaluate empty($v) but empty() does not accept a GMP argument:

// Minimal example in psysh:
$g = gmp_init('0');
=> GMP {#217}
empty($g);
// PHP Recoverable fatal error:  Object of class GMP could not be converted to boolean on line 1

The error needs to be caught to avoid crashing the dumper.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions