-
Notifications
You must be signed in to change notification settings - Fork 48
Rule to enforce class naming #214
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
Comments
I like this idea. |
Another one: all public non-static methods should have a |
This could be a good starting point for the final / abstract part, or as inspiration: https://github.com/ergebnis/phpstan-rules/blob/main/src/Classes/FinalRule.php |
@ruudk I've thrown a PR together implementing my proposal, your proposal for checking methods as well could be added as an additional rule. |
since I also stumbled recently over the "name your abstract test class" with a "TestCase" suffix, I really like this proposal. |
Hey, this isn't generally applicable. The way PHPUnit looks for test files is configurable. It's just that it usually looks like this:
I feel like these suggested rules are too opinionated for the general audience. |
Damn, I'd completely forgotten this was even configurable. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Generally speaking PHPUnit looks for tests in files named
*Test.php
, which conventionally means the classes should be named*Test
. Additionally I believe it is recommended/required (I cannot find docs for this) that "tests" designed to be extended should be named*TestCase
.I propose adding rule to this extension which enforces that classes are named appropriately:
PHPUnit\Framework\TestCase
and it should be named*Test
- could also enforcefinal
?PHPUnit\Framework\TestCase
it should be named*TestCase
.Ideally the rule would also enforce the file is named appropriately as well but that might be outside scope.
If this convention isn't followed and you don't explicitly tell PHPUnit your test files then tests are not run, potentially keeping the build passing because a number of tests are being silently ignored.
The text was updated successfully, but these errors were encountered: