Commit 4877700
committed
PHP 8.0 compatibility: bug fix - ignore annotations are broken
A very recent change in PHP 8.0 changes the possible return values of the `substr()` function from:
> Pre-PHP 8:
> Returns the extracted part of string; or FALSE on failure, or an empty string.
> PHP 8-RC1:
> Returns the extracted part of string; or an empty string.
This is an insidious change as basically all code (strict) checking the return value of `substr()` against `false` will now be broken.
Checking the return value with `empty()` will fix this in a cross-version compatible manner as it allows for both `false` as well as an empty string being returned.
This change broke the ignore annotations as implemented in PHPCS.
The existing unit tests for the ignore annotations cover this change.
Includes removing some unnecessary, duplicate function calls to `substr()`.
Ref: php/php-src#61821 parent 33a4891 commit 4877700
1 file changed
+6
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
| 430 | + | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
| 523 | + | |
524 | 524 | | |
525 | 525 | | |
526 | | - | |
| 526 | + | |
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
| |||
0 commit comments