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

ClassMapGenerator: fix two bugs (long heredocs + markers in text) #10050

Merged

Commits on Aug 11, 2021

  1. ClassMapGenerator: add tests for "long heredoc" bug

    ... to proof the existence of the bug and demonstrate the effect.
    
    Note: in the test the backtrack limit is being lowered (and restored back to the default afterwards) to prevent the tests needing ridiculously huge test fixture files.
    jrfnl committed Aug 11, 2021
    Copy the full SHA
    9588654 View commit details
    Browse the repository at this point in the history
  2. ClassMapGenerator: add test for "marker in text" bug

    In PHP < 7.3, the heredoc/nowdoc marker was allowed to occur in the text, as long as it did not occur at the very start of the line.
    
    This was also not handled correctly.
    
    Ref: https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.heredoc-nowdoc
    jrfnl committed Aug 11, 2021
    Copy the full SHA
    e729c41 View commit details
    Browse the repository at this point in the history
  3. ClassMapGenerator: fix the regex

    By using a look ahead assertion to match "new line - maybe whitespace - marker", the negative performance impact of the `.*` is significantly mitigated and backtracing will be severely limited.
    
    This fixes the bug as reported in 10037.
    
    The bug was discovered due to a PHP 8.1 "passing null to non-nullable" deprecation notice being thrown, but is not a PHP 8.1 bug.
    
    In actual fact, this issue affected all PHP versions and could lead to incomplete classmaps when the code base contained files with huge heredocs/nowdocs.
    
    The regex change (not completely) incidentally also fixes an issue with markers in a heredoc/nowdoc not being correctly handled. This bug could lead to "classes" being added to the class map which aren't actually classes.
    
    Fixes 10037
    jrfnl committed Aug 11, 2021
    Copy the full SHA
    42c6a0d View commit details
    Browse the repository at this point in the history