-
Notifications
You must be signed in to change notification settings - Fork 17
Add support for enum methods #289
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
Conversation
🤔 This will need a way to identify enum scopes without T_ENUM in order to work prior to PHP 7.3 (enums were introduced in PHP 8 but it appears that T_ENUM works in 7.3 🤷 ).
These test failures are really hard to debug. I consistently get failures for PHP 7 and 5.6, but when I run those same tests locally using those versions, everything passes.
Screenshot 2023年03月11日 at 6 37 41 PM
Screenshot 2023年03月11日 at 6 38 31 PM
Even running the sniff itself works as expected (the only error should be on line 33):
Screenshot 2023年03月11日 at 6 41 09 PM
Screenshot 2023年03月11日 at 6 41 30 PM
So why does it fail in Github Actions?
🤔 Ah, it may be something to do with how php or phpcs is installed... T_ENUM is somehow defined on my local machine even for php 5.6 which doesn't seem possible. I have to refactor how we detect classes so it can work for enums without T_ENUM entirely. Still difficult since I can't examine the failing code locally 👎
I figured out how to reproduce the bug! I have to explicitly downgrade phpcs to 3.5.6. I think the issue is that in that version of phpcs, the enum does not get added to the conditions array at all (in fact, it looks like it gets confused by the syntax and adds things like the unrelated case statements to the conditions array). Now maybe I'll get somewhere.
PHPCS 3.5.6 was released in August 2020, way before the idea of Enums ever made it into a PHP RFC,
Support for enums was added in PHPCS 3.7.0.
Ah hah! I think I've got it now. The only failing tests now are the coverage reports which I don't think are related to this PR:
💥 Fixed. I've disabled code coverage for now until it can be fixed but that's outside the scope of this PR.
Hang on, I actually have a commit ready to fix that code coverage for you. Give me a moment to send you a PR.
4a970c5 to
3b3973c
Compare
3b3973c to
bcff821
Compare
This adds support for
enummethods to behave likeclassmethods.Fixes #288