Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BCFile/FunctionDeclarations::get[Method]Properties(): skip over closure use statements #573

Merged

Commits on Apr 3, 2024

  1. BCFile/FunctionDeclarations::get[Method]Properties(): bug fix - skip …

    …over closure use statements
    
    Sister-PR to upstream PR PHPCSStandards/PHP_CodeSniffer 421
    
    This PR improves performance of the `BCFile::getMethodProperties()` and the `FunctionDeclarations::getProperties()` methods and prevents incorrect return type information for closure `use` clauses containing invalid variable imports in the `use` clause (defensive coding).
    
    Closure `use` statements can only import plain variables, not properties or other more complex variables.
    
    As things were, when such "illegal" variables were imported in a closure `use`, the information for the return type could get mangled.
    While this would be a parse error, for the purposes of static analysis, the `BCFile::getMethodProperties()` method and the `FunctionDeclarations::getProperties()` method should still handle this correctly.
    
    This commit updates both methods to always skip over the complete `use` clause, which prevents the issue and improves performance as the same time (less token walking).
    
    Includes unit tests.
    jrfnl committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    7e01385 View commit details
    Browse the repository at this point in the history