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

Use File::getMethodParameters() #149

Open
jrfnl opened this issue Feb 14, 2020 · 5 comments
Open

Use File::getMethodParameters() #149

jrfnl opened this issue Feb 14, 2020 · 5 comments

Comments

@jrfnl
Copy link
Collaborator

jrfnl commented Feb 14, 2020

// 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.

@sirbrillig
Copy link
Owner

It looks like it originated in 2011 here: 385b5a8

Sounds like a great idea to replace that.

@jrfnl
Copy link
Collaborator Author

jrfnl commented Feb 18, 2020

As that would require a refactor and the issue with lists would also be better off with a refactor (and I can think of some additional issues with global and static), we may want to set up a call at some point to discuss how to approach this and who will take care of what, including the implementation of using PHPCSUtils.

@sirbrillig
Copy link
Owner

That sounds like a good idea. A lot of the code in this sniff has been implemented in a "make the tests pass and we can clean it up later" manner, and I think adding PHPCSUtils is an excellent opportunity to do a lot of that clean up.

This week I'm working on launching a major project at work which is taking up pretty much all of my time but I'd love to chat about this in more detail after we're done... maybe next week or the week after?

@jrfnl
Copy link
Collaborator Author

jrfnl commented Feb 18, 2020

I'm prepping for a conference at the moment (or rather: should be) and will be traveling and such for the next two weeks after that. So, realistically, any time after March 9th ;-)

@jrfnl
Copy link
Collaborator Author

jrfnl commented Feb 18, 2020

If you want to have a look at what PHPCSUtils offers in the mean time, the documentation is up: https://phpcsutils.com/ and https://phpcsutils.com/phpdoc/index.html

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

No branches or pull requests

2 participants