Skip to content
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

Report use of binary number format in PHP < 5.4 #55

Closed
MarkMaldaba opened this issue Mar 5, 2015 · 2 comments
Closed

Report use of binary number format in PHP < 5.4 #55

MarkMaldaba opened this issue Mar 5, 2015 · 2 comments
Milestone

Comments

@MarkMaldaba
Copy link
Contributor

PHP 5.4 introduced a new binary number format [1], e.g. 0b001001101 which is invalid syntax in earlier PHP versions.

A sniff should be written to report this when targeting PHP < 5.4.

[1] http://php.net/manual/en/migration54.new-features.php

@MarkMaldaba MarkMaldaba changed the title Report on binary number format on PHP < 5.4 Report use of binary number format in PHP < 5.4 Mar 11, 2015
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Aug 4, 2016
Checks for:
* binary integers which were introduced in PHP 5.4
* invalid octal integers which were truncated prior to PHP 7 and give a parse error in 7.
* hexadecimal numeric strings for which the type juggling behaviour and recognition as numeric was inconsistent prior to PHP 7 and are no longer treated as numeric in PHP 7+.

Includes unit tests.

Closes PHPCompatibility#55
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Aug 8, 2016
Checks for:
* binary integers which were introduced in PHP 5.4
* invalid octal integers which were truncated prior to PHP 7 and give a parse error in 7.
* hexadecimal numeric strings for which the type juggling behaviour and recognition as numeric was inconsistent prior to PHP 7 and are no longer treated as numeric in PHP 7+.

Includes unit tests.

Closes PHPCompatibility#55
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Aug 8, 2016
Checks for:
* binary integers which were introduced in PHP 5.4
* invalid binary integers
* invalid octal integers which were truncated prior to PHP 7 and give a parse error in 7.
* hexadecimal numeric strings for which the type juggling behaviour and recognition as numeric was inconsistent prior to PHP 7 and are no longer treated as numeric in PHP 7+.

Includes unit tests.

Closes PHPCompatibility#55
@jrfnl
Copy link
Member

jrfnl commented Aug 8, 2016

I've been working on this (and some other integer related checks), but am currently staring myself blind at trying to figure out why the unit tests aren't passing...

If anyone feels like having a look, that would be much appreciated.

Work in progress branch (unclean, contains some debug code and such):
https://github.com/jrfnl/PHPCompatibility/tree/feature/binary-int-sniff

Travis run of the unit tests which is failing on the binary int tests:
https://travis-ci.org/jrfnl/PHPCompatibility/builds/150604862

Alternative travis run where I'm running the actual sniff over the test file with various testVersions:
https://travis-ci.org/jrfnl/PHPCompatibility/jobs/150607870

The stupid things is that in the alternative run the errors which we're testing for are being generated correctly for the version where we'd expect them, but when running the unit tests, they seem to be missing.

I did the alternative travis run to see if there was a difference between the results on the travis platform and the results I'm getting locally (there is not) as I can't figure out why the unit tests are not finding the error messages.

Probably something really small and stupid, but I ain't seeing it 😖 😱

jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Aug 13, 2016
Checks for:
* binary integers which were introduced in PHP 5.4
* invalid binary integers
* invalid octal integers which were truncated prior to PHP 7 and give a parse error in 7.
* hexadecimal numeric strings for which the type juggling behaviour and recognition as numeric was inconsistent prior to PHP 7 and are no longer treated as numeric in PHP 7+.

Includes unit tests.

Closes PHPCompatibility#55
jrfnl added a commit to jrfnl/PHPCompatibility that referenced this issue Aug 13, 2016
Checks for:
* binary integers which were introduced in PHP 5.4
* invalid binary integers
* invalid octal integers which were truncated prior to PHP 7 (warning) and give a parse error in 7 (error).
* hexadecimal numeric strings for which the type juggling behaviour and recognition as numeric was inconsistent prior to PHP 7 (warning) and are no longer treated as numeric in PHP 7+(error).

Includes unit tests.

Closes PHPCompatibility#55
@jrfnl
Copy link
Member

jrfnl commented Aug 13, 2016

Found it. See PR #160

@wimg wimg closed this as completed in #160 Aug 13, 2016
@jrfnl jrfnl added this to the 7.0.3 milestone Apr 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants