Conversation
| 82 => 1, | ||
| 84 => 1, | ||
| 86 => 1, | ||
| 90 => 1, |
There was a problem hiding this comment.
So something I noticed generally with the tests in phpcs is that the actual error messages used aren't tested as much - you can see how I addressed tests for sniffs at https://github.com/DanielEScherzer/common-phpcs, I test against the output of the report instead of just the line numbers. Would you be interested in me porting that to phpcs so that we can test error messages too?
There was a problem hiding this comment.
Nice! I am definitely very aware of that problem and have some ideas about this too, but hadn't gotten round to actioning it yet (priorities, priorities).
If you'd be open to it, I'd be very happy to brainstorm the various options (and consequences of those!) in a call some time after next week. Feel free to ping me on Mastodon or X to set up a day/time.
| $scopePtr = $phpcsFile->findPrevious(Tokens::$scopeModifiers, ($stackPtr - 1)); | ||
| $finalPtr = $phpcsFile->findPrevious(T_FINAL, ($stackPtr - 1)); | ||
| if ($finalPtr > $scopePtr) { | ||
| $error = 'The final declaration must come before the visibility declaration'; |
There was a problem hiding this comment.
PSR2 predates final properties, but technically https://www.php-fig.org/psr/psr-2/ just says that final needs to come before visibility and it doesn't limit that to methods, so looks great
There was a problem hiding this comment.
Exactly and yes, I did check PSR-PER before adding this new check 😉
Includes handling the modifier order when `final` is used. This introduces a new `FinalAfterVisibility` error code. Includes tests. Note: the modifier keyword order checks could probably do with some optimization, but that can be handled later.
1313fb0 to
a4eccd3
Compare
|
Rebased without changes before merging. |
Description
Includes handling the modifier order when
finalis used. This introduces a newFinalAfterVisibilityerror code.Includes tests.
Note: the modifier keyword order checks could probably do with some optimization, but that can be handled later.
Suggested changelog entry
finalmodifier keyword is placed before a visibility keyword. Errors will be reported via a newFinalAfterVisibilityerror code.Related issues/external references
Related to #734, follow up to #834 and #907