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

PHP 8.1 support #3479

Closed
8 tasks done
kukulich opened this issue Nov 20, 2021 · 13 comments
Closed
8 tasks done

PHP 8.1 support #3479

kukulich opened this issue Nov 20, 2021 · 13 comments

Comments

@kukulich
Copy link
Contributor

kukulich commented Nov 20, 2021

Issue to track what needs to be done:

@jrfnl
Copy link
Contributor

jrfnl commented Nov 20, 2021

Proposal:

For intersection types, I'd like to propose to re-tokenize to a new PHPCS native T_TYPE_INTERSECTION to prevent sniffs looking for T_BITWISE_AND from getting confused and starting to try and handle the token.

This is in-line with the changes made for PHP 8.0 union types (see #3032 and #3302).

Note: the File::getMethodParameters(), File::getMethodProperties() and File::getMemberProperties() methods will also need adjusting.


Also note that the File::getMemberProperties() method also still needs adjusting for the readonly keyword.

@jrfnl
Copy link
Contributor

jrfnl commented Nov 20, 2021

Check sniffs that use Tokens::$ooScopeTokens

For all Tokens arrays being updated with new tokens:

  • Check every single PHPCS native sniff using them for either handling the new syntax correctly or bowing out.
  • No matter what the decision: add a couple of tests to each of these sniffs to guard against the sniff throwing false positives for the new syntax/fixing things incorrectly etc.
  • Even when not using the Tokens arrays, see if sniffs looking for "similar" tokens need to add support for the new syntaxes.
    Think for example: sniffs which looks at type declarations in a function declaration will now also need to handle intersection types and never. In most cases, those sniffs will use the File::getMethodParameters() and File::getMethodProperties(), so instead of doing a token search, do a search for usage of these methods and review each sniff using them.

@gsherwood gsherwood added this to Idea Bank in PHPCS v3 Development via automation Nov 21, 2021
@gsherwood gsherwood added this to the 3.7.0 milestone Nov 21, 2021
@MarkBaker
Copy link
Contributor

MarkBaker commented Dec 23, 2021

Addition to the list:

  • Support for first class callable syntax

e.g.

$result = array_map(trim(...), $array);

At the moment, this tokenises to T_ELLIPSIS; but it might be a good idea to change that to a new token (T_FIRST_CLASS_CALLABLE) which will then make the usage explicit

@jrfnl
Copy link
Contributor

jrfnl commented Dec 24, 2021

At the moment, this tokenises to T_ELLIPSIS; but it might be a good idea to change that to a new token (T_FIRST_CLASS_CALLABLE) which will then make the usage explicit

For the purpose of writing sniffs, I think it is completely unnecessary to retokenize that. Use as a first class callable is straightforward to detect (is the next non-empty token a close parenthesis ?).

Retokenizing to a PHPCS native token constant is generally only done when it would need a lot of logic within a sniff to determine whether the token is the target token, or when not retokenizing would lead to lots of false positives in pre-existing sniffs.

Neither applies.

@jrfnl
Copy link
Contributor

jrfnl commented Jan 5, 2022

To add to the list:

@nunoperalta
Copy link

I was about to report the same as #557

enum being detected as GOTO:

enum Suit: string {
	case Hearts = 'H';
	case Diamonds = 'D';
	case Clubs = 'C';
	case Spades = 'S';
}

Use of the GOTO language construct is discouragedPHPCS(Generic.PHP.DiscourageGoto.Found)

@jrfnl
Copy link
Contributor

jrfnl commented Feb 3, 2022

@nunoperalta There is already a PR open to fix that: #3534

@nunoperalta
Copy link

@jrfnl nice one! Any idea when it will be merged? I see it's been there for 15 days. Thank you very much.

@jrfnl
Copy link
Contributor

jrfnl commented Feb 3, 2022

nice one! Any idea when it will be merged?

@nunoperalta When the maintainers have time to review.

@acidjazz
Copy link

👀 @jrfnl @gsherwood @michalbundyra @gmponos 👀

@acidjazz
Copy link

acidjazz commented Mar 23, 2022

@gsherwood @jrfnl @kukulich loving and using Enums in all of my current projects

is it possible at all to just get #3482 merged and release that?

gbirke pushed a commit to wmde/fundraising-payments that referenced this issue Apr 27, 2022
- it was hard to look up the payment status through the payment specific fields
- enable easier lookup

This commit can be reverted when doing squizlabs/PHP_CodeSniffer#3479
gbirke pushed a commit to wmde/fundraising-payments that referenced this issue May 2, 2022
- it was hard to look up the payment status through the payment specific fields
- enable easier lookup

This commit can be reverted when doing squizlabs/PHP_CodeSniffer#3479
@kukulich
Copy link
Contributor Author

Everything is solved now in master.

PHPCS v3 Development automation moved this from Idea Bank to Ready for Release May 18, 2022
@mreduar
Copy link

mreduar commented May 18, 2022

Thank you!! When will the release be made?

gbirke pushed a commit to wmde/fundraising-payments that referenced this issue Aug 29, 2022
- it was hard to look up the payment status through the payment specific fields
- enable easier lookup

This commit can be reverted when doing squizlabs/PHP_CodeSniffer#3479
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
PHPCS v3 Development
Ready for Release
Development

No branches or pull requests

7 participants