-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Correct Some Problems Which Will Show Up for PHP8.1 #2191
Conversation
Just reviewing Scrutinizer's list of "bugs". There are 19 ascribed to me. For some, I will definitely take no action (e.g. use of bitwise operators in AND, OR, and XOR functions). However, where I can clean things up so that Scrutinizer is satisfied and the resulting code is not too contorted, I will make an attempt. I believe this is the only one with which will involve more than 2 or 3 changes. It fixes 5 items ascribed to me, and 4 to others.
Per suggestion from Mark Baker.
PHP8.1 wants to issue a message when you use a float where it thinks you ought to be using an int (it wants its implicit casts made explicit). This is causing unit tests to fail. The following corrections are made in this PR: - Calculation.php tests `isset(self::binaryOperators[$token])`, where token can be a float. No numeric values are members of that array, so we can test for numeric before isset. - SharedOle.php packs a float, intending it as an int, in 2 places. I simplified the logic here, and added explicit casts to avoid the problem. This is used by Xls Reader and Writer; as added confirmation, I added some timestamps from before 1970 (i.e. negative values) to Document/EpochTest. Because of this, the test suite has been verified for 32-bit PHP as well as PHP 8.1. - Writer/Xlsx/StringTable tests `isset($aFlippedStringTable[$cellValue])`. This is the same problem as in Calculation, but requires a different solution. The same if statement here also tests that the datatype is string, but it does so after the isset test. Changing the order of these tests avoids the problem. There remain PHP8.1 errors having to do with vendor code used as a polyfill for Enum. @MarkBaker has reported the issue to the vendor.
Apologies for the multiple commits. I started out from the wrong baseline. |
Enum polyfill issue has now been resolved |
Three issues now remain for PHP 8.1, all in mPdf |
FWIW, I reported the Mpdf Php8.1 issues a while back. They closed my ticket immediately, and were, I thought, quite rude about it. The fix on their side is really easy, but I'm not going to attempt it again. Perhaps you'll have better luck. There is still an issue with LocaleFloatsTest. It fortuitously is skipped because there is no "French" environment set up when Github runs the unit tests. However, if there were one, the test would fail, for the same reason as I thought it would fail for 8.0 (issue #1663). |
This is:
Checklist:
Why this change is needed?
Correct Some Problems Which Will Show Up for PHP8.1
PHP8.1 wants to issue a message when you use a float where it thinks you ought to be using an int (it wants its implicit casts made explicit). This is causing unit tests to fail. The following corrections are made in this PR:
isset(self::binaryOperators[$token])
, where token can be a float. No numeric values are members of that array, so we can test for numeric before isset.isset($aFlippedStringTable[$cellValue])
. This is the same problem as in Calculation, but requires a different solution. The same if statement here also tests that the datatype is string, but it does so after the isset test. Changing the order of these tests avoids the problem.There remain PHP8.1 errors having to do with vendor code used as a polyfill for Enum. @MarkBaker has reported the issue to the vendor.