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

Feature suggestion: utilities to examine PHP attributes #616

Open
1 task done
jrfnl opened this issue Jul 28, 2024 · 0 comments
Open
1 task done

Feature suggestion: utilities to examine PHP attributes #616

jrfnl opened this issue Jul 28, 2024 · 0 comments

Comments

@jrfnl
Copy link
Member

jrfnl commented Jul 28, 2024

Is your feature request related to a problem?

PHP 8.0 introduced attributes.

Attributes can reference either a single attribute class or multiple attribute classes.

While splitting the attribute up to its individual parts and potentially retrieving a list of attribute class names is not that hard to do, it still makes for duplicate code and could benefit from caching if this action is executed in multiple sniffs.

#[MyAttributeA(12, 34), MyAttributeB(5678)]

Describe the solution you'd like

I imagine a new PHPCSUtils\Utils\Attributes utility class could be added with one or more helper methods, the precise form these will take, is yet to be determined.

Additional context (optional)

The above could also benefit from the namespace resolution features which are already planned for PHPCSUtils.

Also note that the PassedParameters class can already handle parsing the parameters passed to an attribute class.

This ticket is inspired by PHPCompatibility/PHPCompatibility#1480

  • I intend to create a pull request to implement this feature.
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

1 participant