Skip to content

Use File::getMethodParameters() #149

Description

@jrfnl

// Are we a function or closure parameter?
// It would be nice to get the list of function parameters from watching for
// T_FUNCTION, but AbstractVariableSniff and AbstractScopeSniff define everything
// we need to do that as private or final, so we have to do it this hackish way.

I have no clue how old that comment is, but it definitely isn't valid anymore and hasn't been valid for a long time.

The File::getMethodParameters() utility method can retrieve information on all declared parameters for functions, closures (since PHPCS 2.8.0), arrow functions (since PHPCS 3.5.4) and closure use statements (since PHPCS 3.5.0).

Ref: https://pear.php.net/package/PHP_CodeSniffer/docs/3.5.4/apidoc/PHP_CodeSniffer/File.html#methodgetMethodParameters

To change this would probably require a refactor, but it would also make the code more stable and simpler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions