-
Notifications
You must be signed in to change notification settings - Fork 44
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
Error when attempting to upgrade to PHP8 #78
Comments
That is a false-positive because the
So no casting from hex to int happens. P.S. |
The test seems to think that this use: hamcrest-php/tests/Hamcrest/Type/IsNumericTest.php Lines 28 to 29 in 8c3d0a3
is a use of hex strings in a function which isn't known to support them: The inconsistent behavior before PHP 7 is noted in the RFC that removed hex support: https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings
Just to cover edge cases, should the test case assert that the nonzero numbers given in this test suite are nonzero in addition to being |
@benlk , As per my understanding the PHPCompatibility sniff reported a false-positive here because the code you've mentioned doesn't cause any test failures on any of the tested PHP versions (5.x, 7.x, 8.0). What are you suggesting exactly? |
As written, yes, this seems like a false positive, but it's alerted us to a deeper problem: Using
The assertion |
@benlk , looking at https://github.com/hamcrest/hamcrest-php/blob/master/hamcrest/Hamcrest/Type/IsNumeric.php#L30 method comment the code is expected to work like this: interpret hex numbers in any form (hex, string) as hex numbers and validate them. |
Yes, that's what the method does. I'm calling into doubt whether that is the correct approach. Should this package reply "yes, it is numeric" if the language says "no, it is not numeric"? Who is the proper source of truth about the numeric-ness of the string? Should Hamcrest reflect what PHP says is true, or a language-agnostic truth? |
This library attempts to mirror the original library version written in Java with some adaptations to PHP-specific stuff. Not sure if the library should preserve BC of its method logic across all PHP versions or break it when PHP versions do. I wish some of the other library maintainers could express some opinion on this topic. |
Morning! I would err on the side of caution here and maintain BC, but easy enough to raise a deprecation warning? It's hard to say what the users would expect here, if they're checking something is numeric for output, we're all good as we are, but if they are heading for casts or calculations, we need to potentially warn the user and they would need to make changes? |
Hello,
We are attempting to upgrade our project to PHP8, and this error was surfaced by PHPCodesniffer and PHPCompatibility checker against PHP 8. Do you have any more information about this error?
The text was updated successfully, but these errors were encountered: