-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic/AbstractClassNamePrefix: improve the tests further
* Remove redundant whitespace in the test case file. * Adjust some existing tests to have comments and new lines in unexpected places. * Add a few comments to pre-existing tests to clarify why they exist. * Add extra test with `abstract readonly` class but with keywords in reverse order. * Annotate two new tests with `// Error.` to be consistent with the rest of the tests in the file.
- Loading branch information
Showing
2 changed files
with
22 additions
and
41 deletions.
There are no files selected for viewing
54 changes: 17 additions & 37 deletions
54
src/Standards/Generic/Tests/NamingConventions/AbstractClassNamePrefixUnitTest.1.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,43 @@ | ||
<?php | ||
|
||
abstract class IncorrectName // Error. | ||
{ | ||
abstract class IncorrectName {} // Error. | ||
|
||
} | ||
|
||
abstract class AbstractCorrectName | ||
{ | ||
|
||
} | ||
|
||
abstract class IncorrectNameAbstract // Error. | ||
{ | ||
|
||
} | ||
|
||
abstract class InvalidNameabstract // Error. | ||
{ | ||
abstract class AbstractCorrectName {} | ||
|
||
} | ||
abstract class IncorrectNameAbstract {} // Error. | ||
|
||
abstract class IncorrectAbstractName // Error. | ||
{ | ||
abstract | ||
/*comment*/ | ||
class | ||
InvalidNameabstract {} // Error. | ||
|
||
} | ||
abstract class /*comment*/ IncorrectAbstractName {} // Error. | ||
|
||
// Anonymous classes can't be declared as abstract (and don't have a name anyhow). | ||
$anon = new class {}; | ||
|
||
class AbstractClassName | ||
{ | ||
|
||
} | ||
// Make sure that if the class is not abstract, the sniff does not check the name. | ||
class AbstractClassName {} | ||
|
||
// Class name is always checked, doesn't matter if the class is declared conditionally. | ||
if (!class_exists('AbstractClassCorrectName')) { | ||
abstract class AbstractClassCorrectName | ||
{ | ||
|
||
} | ||
abstract class AbstractClassCorrectName {} | ||
} | ||
if (!class_exists('ClassAbstractIncorrectName')) { | ||
abstract class ClassAbstractIncorrectName // Error. | ||
{ | ||
|
||
} | ||
abstract class ClassAbstractIncorrectName {} // Error. | ||
} | ||
|
||
$var = 'abstract class TextStringsAreDisregarded'; | ||
|
||
class NotAnAbstractClassSoNoPrefixRequired {} | ||
|
||
abstract class abstractOkCaseOfPrefixIsNotEnforced | ||
{ | ||
|
||
} | ||
abstract class abstractOkCaseOfPrefixIsNotEnforced {} | ||
|
||
final class FinalClassShouldNotTriggerWarning {} | ||
|
||
readonly class ReadonlyClassShouldNotTriggerWarning {} | ||
|
||
abstract readonly class AbstractReadonlyClassWithPrefixShouldNotTriggerWarning {} | ||
|
||
abstract readonly class ReadonlyAbstractClassShouldTriggerWarningWhenPrefixIsMissing {} | ||
abstract readonly class ReadonlyAbstractClassShouldTriggerWarningWhenPrefixIsMissingA {} // Error. | ||
readonly abstract class ReadonlyAbstractClassShouldTriggerWarningWhenPrefixIsMissingB {} // Error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters