PHPCompatibility / PHPCompatibility

PHP Compatibility check for PHP_CodeSniffer

Home Page:http://techblog.wimgodden.be/tag/codesniffer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

number_format(): 'multi-byte separator not supported' is misreported when separator is empty.

MarkMaldaba opened this issue · comments

Minimal test file

<?php
print(number_format(1234, 2, '.', ''));

Command line

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

Expected Behaviour

No compatibility issue reported. The empty string is not a multi-byte character.

Actual Behaviour

E 1 / 1 (100%)



FILE: D:\PHP Compatibility Testing\file.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 2 | ERROR | Passing a multi-byte separator as the $thousands_separator to number_format() is not supported in PHP 5.3
   |       | or earlier. Found: ""
------------------------------------------------------------------------------------------------------------------------

Time: 184ms; Memory: 10MB

Environment

Environment Answer
PHP version 7.4.13
PHP_CodeSniffer version 3.7.2 (stable)
PHPCSUtils version ???
PHPCompatibility version develop @ 34a67f7
Install type git

Tested Against develop branch?

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

You are 100% correct. Thanks for reporting this @MarkMaldaba ! PR #1680 should fix this. Testing appreciated.