Skip to content

Hexadecimal strings are still supported #1345

@MPParsley

Description

@MPParsley

Bug Description

Hexadecimal strings cause an error.

Given the following reproduction Scenario

The following code:

        // 11 bits of biased exponent
        $exp = (gmp_and($n, '0x7ff0000000000000') >> 52) + self::EXP_BIAS;
        // 52 bits of mantissa
        $man = gmp_and($n, '0xfffffffffffff');

See sop/asn1#19 & sop/asn1#18.

The issue happens when running this command:

phpcs -ps file.php --standard=PHPCompatibility --runtime-set testVersion #.#-

over a file containing this code:

hexdec('0x7ff0000000000000');

I'd expect the following behaviour

No Error.

Instead this happened

 531 | ERROR | The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: '0x7ff'
 533 | ERROR | The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: '0xffff'

Environment

Environment Answer
PHP version 8.1.9
PHP_CodeSniffer version 3.7.1
PHPCompatibility version latest
Install type Composer project local

Additional Context (optional)

hexadecimal number support has been removed from is_numeric but should still be supported for other functions (e.g. hexdec, gmp_and).

Hexadecimal strings are no longer considered numeric[ ¶](https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.strings.hex)
Strings containing hexadecimal numbers are no longer considered to be numeric. For example:

source https://www.php.net/manual/en/migration70.incompatible.php

Tested Against develop branch?

  • I have verified the issue still exists in the develop branch of PHPCompatibility.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions