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

Ignore annotations are broken on PHP 8.0 #3135

Commits on Oct 4, 2020

  1. 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#6182
    jrfnl committed Oct 4, 2020
    Configuration menu
    Copy the full SHA
    4877700 View commit details
    Browse the repository at this point in the history