Running phpcs --standard=PHPCompatibility reports few issues with PHP compatibility.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3104420.patch | 1.69 KB | peterkokot |
Running phpcs --standard=PHPCompatibility reports few issues with PHP compatibility.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3104420.patch | 1.69 KB | peterkokot |
Comments
Comment #2
peterkokot commentedComment #3
mondrakeThis is not sufficient, we also need to cast explicitly $key to string because it could be an int, and in this case the array acccess would fail. See #3086374: Make Drupal 8 & 9 compatible with PHP 7.4.
Comment #4
peterkokot commentedHello, yes, true. In the next patch file type casting to string has been added and checking if string starts with changed to substr usage...
Comment #5
mondrakeComment #6
mondrakeComment #7
mondrakeWhy overwriting $key and not just
if ((string) $key[0] !== '_') {?Comment #8
peterkokot commentedOtherwise for integers this notice is emitted: Trying to access array offset on value of type int...
$key could theoretically be also empty string. And then substr is a bit better pick instead of $key[0]. This might also work instead of overwriting the $key:
Comment #9
mondrakeYes, see https://3v4l.org/fEg4g.
Let's do #8 then.
Comment #10
peterkokot commentedComment #11
mondrakeLooks good to me.
Comment #12
alexpottCommitted eb5e8d5 and pushed to 9.0.x. Thanks! >
Backported to 8.9.x and 8.8.x as low risk and no-change bug fix.