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

Review sniff handling of PHP 7.4 arrow functions #1834

Closed
jrfnl opened this issue Nov 7, 2019 · 3 comments
Closed

Review sniff handling of PHP 7.4 arrow functions #1834

jrfnl opened this issue Nov 7, 2019 · 3 comments

Comments

@jrfnl
Copy link
Member

jrfnl commented Nov 7, 2019

PHP 7.4 introduces short closures/arrow functions.

The WPCS native sniffs will need to be reviewed to make sure that they handle those correctly.

  • Any sniff which examines function declarations will need the T_FN token added.
  • Any sniff which examines the => T_DOUBLE_ARROW token will need unit tests added to make sure the double arrow in arrow functions is handled correctly or ignored, depending on the purpose of the sniff.
  • ... tbd ...

Refs:

Related to #764

@jrfnl
Copy link
Member Author

jrfnl commented Dec 4, 2019

As of PHPCS 3.5.3, PHPCS backfills the T_FN token and will tokenize the => for arrow functions as T_FN_ARROW.

@jrfnl
Copy link
Member Author

jrfnl commented Mar 14, 2020

PHPCSUtils contains a few utilities for recognizing arrow functions correctly for those PHPCS versions which don't properly support them yet (=all currently released versions. Support was added in 3.5.3, but very buggy and the latest bug fixes haven't been released yet)

@jrfnl jrfnl added this to the 3.0.0 milestone Apr 1, 2020
@jrfnl
Copy link
Member Author

jrfnl commented Aug 18, 2023

All sniffs have been reviewed and fixed to support modern PHP in as far as my imagination reached.

If any more situations would be discovered which need to be taken into account, a new issue should be opened with code samples etc.

Closing this now as fixed.

@jrfnl jrfnl closed this as completed Aug 18, 2023
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