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

Support new PHP 8.4 syntaxes #734

Open
43 tasks
jrfnl opened this issue Nov 26, 2024 · 0 comments
Open
43 tasks

Support new PHP 8.4 syntaxes #734

jrfnl opened this issue Nov 26, 2024 · 0 comments

Comments

@jrfnl
Copy link
Member

jrfnl commented Nov 26, 2024

PHP 8.4 introduces new syntaxes for which it should be verified if the Tokenizer needs updates and/or whether any sniffs need updating.

Action list

Notes:

  • While Property Hooks is a single RFC, it introduces multiple new syntaxes. With that in mind, I've broken the RFC up into separately actionable parts.
  • Action items in italics are tentative. Investigation and testing is needed to determine whether any changes are needed and if so, which.
  • For action items not in italics, I'm fairly certain those will be needed.
  • This list is not set in stone and is subject to change once investigation for supporting a syntax starts.

To Do

  • Asymmetric Visibility v2
    • Proposal needed on how to handle this for the tokenizer
    • Tokenizer changes needed - property declarations
    • Tokenizer changes needed - constructor property promotion
    • Updates needed to the predefined token collections in the Tokens class
    • Updates needed to utility functions - getMemberProperties(), getMethodParameters() (for constructor property promotion)
      These updates should include special handling for the abbreviated form.
    • Updates needed to abstract sniffs ?
      This needs investigation, but I imagine the AbstractScopeSniff and the AbstractVariableSniff might need updates.
    • Sniff updates needed
  • new MyClass()->method() without parentheses
    • Tokenizer changes needed ?
    • Updates needed to utility functions ?
    • Sniff updates needed ? (or possibly only sniff test updates?)
  • Property hooks - final properties
    • Tokenizer changes needed ?
    • Updates needed to utility functions - getMemberProperties(), getMethodParameters() (for constructor property promotion)
    • Sniff updates needed
  • Property hooks - abstract properties
    • Tokenizer changes needed ?
    • Updates needed to utility functions - getMemberProperties(), getMethodParameters() (for constructor property promotion)
    • Sniff updates needed
  • Property hooks - properties on interfaces
    • Tokenizer changes needed ?
    • Updates needed to utility functions - getMemberProperties(), getMethodParameters() (for constructor property promotion)
    • Sniff updates needed
  • Property hooks - hook syntax, long form
    • Proposal needed on how to handle this for the tokenizer
    • Tokenizer changes needed
    • Updates needed to utility functions - getMemberProperties()
    • Sniff updates needed
  • Property hooks - hook syntax. short (arrow) form
    • Proposal needed on how to handle this for the tokenizer
    • Tokenizer changes needed
    • Updates needed to utility functions - getMemberProperties()
    • Sniff updates needed
  • Property hooks - hook syntax. other short form variations
    • Proposal needed on how to handle this for the tokenizer
    • Tokenizer changes needed
    • Updates needed to utility functions - getMemberProperties()
    • Sniff updates needed
  • Property hooks - hook syntax for abstract properties/interface properties (no body)
    • Proposal needed on how to handle this for the tokenizer
    • Tokenizer changes needed
    • Updates needed to utility functions ?
    • Sniff updates needed
  • Property hooks - hook syntax in constructor property promotion, long form
    • Tokenizer changes needed
    • Updates needed to utility functions - getMethodParameters()
    • Sniff updates needed
  • Property hooks - hook syntax in constructor property promotion, short form
    • Tokenizer changes needed
    • Updates needed to utility functions - getMethodParameters()
    • Sniff updates needed
  • Property hooks - availability of "magic" variable within hook functions
    • Updates needed to utility functions ? - getMethodParameters() ?
    • Sniff updates needed ?

Done

Nothing yet.

No action needed

Contribution Process

If anyone familiar with the PHP and PHPCS tokenizer wants to start work on any of these, please leave a comment in this ticket to claim an action item.

If you are not familiar with either tokenizer, please spare yourself the pain 😉

New custom PHPCS tokens may be needed (like for supporting property hooks). If that's the case, please open a separate issue with a detailed proposal on how to handle the syntax, what alternatives have been considered, what the consequences would be and why the proposed option should be accepted. Please open this issue before creating a PR.

If anyone needs it, here are some examples of earlier proposals for supporting PHP syntaxes from before PHP 8.4:

Timeline

For anyone coming to this ticket to see when syntax support for PHP 8.4 syntaxes is expected, please do NOT spam this ticket with repeated comments asking for a timeline.
It will be ready when it's ready and whatever is ready will be included in a release forthwith.

Seriously, to add syntax support for PHP 8.4, a completely silly amount of work will be needed and people need to sleep once in a while as well (and should get a life), so please be patient.

To quote myself from #731 (comment):

... property hooks is the bane of my existence and will be a nightmare to add support for in PHPCS. The tokenizer support alone is going to take months of work, as it is not 1 syntax they have added, but over a dozen new syntaxes, all under one RFC...
Only after syntax support is available through the Tokenizer can we start fixing individual sniffs and I expect 60-70% of sniffs in the wider PHPCS field (including external standards) will need updates, or at the very least additional tests with property hooks.

I spoke up about this at the time (and about other idiocracies in property hooks, it's a massive footgun), but unfortunately to no avail.
If you want to read my full analysis of the problems with property hooks, have a read through here: https://externals.io/message/123048#123080

Oh and this comment from me on the Internals mailinglist should also help illuminate why so many sniffs will need updates and how problematic property hooks are: https://externals.io/message/123048#123118

All in all, please be patient, I expect it will be quite a while before PHPCS will have full support for property hooks.

Funding for this would help. Finding a way to clone me, would help even more.

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