@@ -108,7 +108,6 @@ public static function dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTes
108
108
'Unqualified class name ' => ['ClassName ' ],
109
109
'Fully qualified class name, not enough parts ' => ['Fully \\Qualified \\ClassName ' ],
110
110
'Fully qualified class name, doesn \'t end on Sniff or UnitTest ' => ['Fully \\Sniffs \\Qualified \\ClassName ' ],
111
- 'Fully qualified class name, ends on Sniff, but isn \'t ' => ['Fully \\Sniffs \\AbstractSomethingSniff ' ],
112
111
];
113
112
114
113
}//end dataGetSniffCodeThrowsExceptionOnInputWhichIsNotASniffTestClass()
@@ -141,30 +140,58 @@ public function testGetSniffCode($fqnClass, $expected)
141
140
public static function dataGetSniffCode ()
142
141
{
143
142
return [
144
- 'PHPCS native sniff ' => [
143
+ 'PHPCS native sniff ' => [
145
144
'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Sniffs \\Arrays \\ArrayIndentSniff ' ,
146
145
'expected ' => 'Generic.Arrays.ArrayIndent ' ,
147
146
],
148
- 'Class is a PHPCS native test class ' => [
147
+ 'Class is a PHPCS native test class ' => [
149
148
'fqnClass ' => 'PHP_CodeSniffer \\Standards \\Generic \\Tests \\Arrays \\ArrayIndentUnitTest ' ,
150
149
'expected ' => 'Generic.Arrays.ArrayIndent ' ,
151
150
],
152
- 'Sniff in external standard without namespace prefix ' => [
151
+ 'Sniff in external standard without namespace prefix ' => [
153
152
'fqnClass ' => 'MyStandard \\Sniffs \\PHP \\MyNameSniff ' ,
154
153
'expected ' => 'MyStandard.PHP.MyName ' ,
155
154
],
156
- 'Test in external standard without namespace prefix ' => [
155
+ 'Test in external standard without namespace prefix ' => [
157
156
'fqnClass ' => 'MyStandard \\Tests \\PHP \\MyNameSniff ' ,
158
157
'expected ' => 'MyStandard.PHP.MyName ' ,
159
158
],
160
- 'Sniff in external standard with namespace prefix ' => [
159
+ 'Sniff in external standard with namespace prefix ' => [
161
160
'fqnClass ' => 'Vendor \\Package \\MyStandard \\Sniffs \\Category \\AnalyzeMeSniff ' ,
162
161
'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
163
162
],
164
- 'Test in external standard with namespace prefix ' => [
163
+ 'Test in external standard with namespace prefix ' => [
165
164
'fqnClass ' => 'Vendor \\Package \\MyStandard \\Tests \\Category \\AnalyzeMeUnitTest ' ,
166
165
'expected ' => 'MyStandard.Category.AnalyzeMe ' ,
167
166
],
167
+
168
+ /*
169
+ * These are not valid sniff codes and is an undesirable result, but can't be helped
170
+ * as changing this would be a BC-break.
171
+ * Supporting these to allow for <rule> tags directly including sniff files.
172
+ * See: https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/675
173
+ */
174
+
175
+ 'Fully qualified class name, ends on Sniff, but isn \'t ' => [
176
+ 'fqnClass ' => 'Fully \\Sniffs \\AbstractSomethingSniff ' ,
177
+ 'expected ' => '.Sniffs.AbstractSomething ' ,
178
+ ],
179
+ 'Sniff provided via file include and doesn \'t comply with naming conventions [1] ' => [
180
+ 'fqnClass ' => 'CheckMeSniff ' ,
181
+ 'expected ' => '..CheckMe ' ,
182
+ ],
183
+ 'Sniff provided via file include and doesn \'t comply with naming conventions [2] ' => [
184
+ 'fqnClass ' => 'CompanyName \\CheckMeSniff ' ,
185
+ 'expected ' => '.CompanyName.CheckMe ' ,
186
+ ],
187
+ 'Sniff provided via file include and doesn \'t comply with naming conventions [3] ' => [
188
+ 'fqnClass ' => 'CompanyName \\Sniffs \\CheckMeSniff ' ,
189
+ 'expected ' => '.Sniffs.CheckMe ' ,
190
+ ],
191
+ 'Sniff provided via file include and doesn \'t comply with naming conventions [4] ' => [
192
+ 'fqnClass ' => 'CompanyName \\CustomSniffs \\Whatever \\CheckMeSniff ' ,
193
+ 'expected ' => 'CompanyName.Whatever.CheckMe ' ,
194
+ ],
168
195
];
169
196
170
197
}//end dataGetSniffCode()
0 commit comments