Skip to content

Support new PHP 8.4 syntaxes #734

Open

Description

@jrfnl

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.

Action list

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.

Activity

  1. pinned this issue on Nov 26, 2024
  2. paulshryock commented on Feb 11, 2026

    @paulshryock

    Hello, are property hooks with curly braces supported in PHP_CodeSniffer 4.0.1?

    This is getting flagged:

    <?php
    
    interface Thing {
      public string $id { get; }
    }
    4 | ERROR | [x] Curly brace syntax for accessing array elements and string offsets has been deprecated in PHP 7.4 and removed in PHP 8.0. Found: $id { get; }
      |       |     (PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess.Removed)
  3. rodrigoprimo commented on Feb 12, 2026

    @rodrigoprimo
    Contributor

    Hi @paulshryock,

    I'm not a maintainer of this project, so this is not an official response. I'm just going by the issue description and my experience as a contributor to this project.

    No, property hooks are not yet supported in PHPCS. As you can see in the action list in the issue description, most items related to property hooks remain unchecked.

    The error you are seeing is from the PHPCompatibility standard, not from PHPCS core. I haven't checked, but I believe that since PHPCS doesn't yet understand the property hook syntax, the tokenizer doesn't recognize the curly braces after $id as being part of a property hook declaration, and the PHPCompatibility sniff misinterprets them as the deprecated curly brace array access syntax.

  4. nlighteneddesign commented on Feb 21, 2026

    @nlighteneddesign

    Is there anything a new contributor can do to help with property hook support?

  5. jrfnl commented on Feb 22, 2026

    @jrfnl
    MemberAuthor

    @nlighteneddesign Well, surfacing test code, especially edge cases which need to be taken into account, would be helpful, but more than anything this needs funding.

    I estimate it would take me 2 to 3 months of work to get property hooks properly sorted in all places it needs support and, aside from needing to find the time, I also can't justify spending that amount of time without compensation.
    Keep in mind that the last 7 months of 2025 were unpaid too as the budget for the whole year went to getting PHPCS 4.0 released.

  6. nlighteneddesign commented on Feb 23, 2026

    @nlighteneddesign

    Thank you @jrfnl! I will take a look.

    Just a little background, I come from the Drupal community and we are looking to use entity hooks to help with some Fiber related issues we are experiencing.

    I saw some interest this morning in assisting with this since it affects the Tokenizer so currently if you use entity hooks you have to disable the whole file from scanning.

    Hopefully we can help get this supported!

  7. jrfnl commented on Mar 2, 2026

    @jrfnl
    MemberAuthor

    Just FYI - in the mean time I've pulled a fix for the issue reported by @paulshryock : PHPCompatibility/PHPCompatibility#2026

    Once merged, that should at least prevent that particular false positive (and prevent the fixer from making incorrect fixes).

    Not a solution, but still a little bit of a stopgap.

  8. paulshryock commented on Mar 3, 2026

    @paulshryock

    that should at least prevent that particular false positive (and prevent the fixer from making incorrect fixes)

    Thank you!

  9. beberlei commented on Nov 1, 2026

    @beberlei

    @jrfnl The "Property Hooks" tokenizer proposal you asked for in #1442 exists: @alekitto opened #1443. It is not linked from the list above and has no labels, so it seems to have dropped out of triage — could you link it against the two hook syntax items and label it? (#1493, #1494 and #1495 are sniff fallout from the same gap, if you want them cross-linked under Sniff updates needed.)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions