@@ -34,8 +34,8 @@ final class SetSniffPropertyTest extends TestCase
34
34
*/
35
35
public function testSniffPropertiesGetSetWhenAllowed ($ name )
36
36
{
37
- $ sniffCode = "Fixtures.Category . {$ name }" ;
38
- $ sniffClass = 'Fixtures\Sniffs\Category \\' .$ name .'Sniff ' ;
37
+ $ sniffCode = "Fixtures.SetProperty . {$ name }" ;
38
+ $ sniffClass = 'Fixtures\Sniffs\SetProperty \\' .$ name .'Sniff ' ;
39
39
$ properties = [
40
40
'arbitrarystring ' => 'arbitraryvalue ' ,
41
41
'arbitraryarray ' => [
@@ -45,7 +45,7 @@ public function testSniffPropertiesGetSetWhenAllowed($name)
45
45
];
46
46
47
47
// Set up the ruleset.
48
- $ standard = __DIR__ ."/ {$ name }Test.xml " ;
48
+ $ standard = __DIR__ ."/SetProperty {$ name }Test.xml " ;
49
49
$ config = new Config (["--standard= $ standard " ]);
50
50
$ ruleset = new Ruleset ($ config );
51
51
@@ -72,14 +72,14 @@ public function testSniffPropertiesGetSetWhenAllowed($name)
72
72
*
73
73
* @see self::testSniffPropertiesGetSetWhenAllowed()
74
74
*
75
- * @return array
75
+ * @return array<string, array<string>>
76
76
*/
77
77
public static function dataSniffPropertiesGetSetWhenAllowed ()
78
78
{
79
79
return [
80
- 'Property allowed as explicitly declared ' => ['SetPropertyAllowedAsDeclared ' ],
81
- 'Property allowed as sniff extends stdClass ' => ['SetPropertyAllowedViaStdClass ' ],
82
- 'Property allowed as sniff has magic __set() method ' => ['SetPropertyAllowedViaMagicMethod ' ],
80
+ 'Property allowed as explicitly declared ' => ['AllowedAsDeclared ' ],
81
+ 'Property allowed as sniff extends stdClass ' => ['AllowedViaStdClass ' ],
82
+ 'Property allowed as sniff has magic __set() method ' => ['AllowedViaMagicMethod ' ],
83
83
];
84
84
85
85
}//end dataSniffPropertiesGetSetWhenAllowed()
@@ -163,7 +163,7 @@ public function testSetPropertyThrowsErrorOnInvalidProperty()
163
163
public function testSetPropertyThrowsErrorWhenPropertyOnlyAllowedViaAttribute ()
164
164
{
165
165
$ exceptionClass = 'PHP_CodeSniffer\Exceptions\RuntimeException ' ;
166
- $ exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.Category.SetPropertyNotAllowedViaAttribute ' ;
166
+ $ exceptionMsg = 'Ruleset invalid. Property "arbitrarystring" does not exist on sniff Fixtures.SetProperty.NotAllowedViaAttribute ' ;
167
167
if (method_exists ($ this , 'expectException ' ) === true ) {
168
168
$ this ->expectException ($ exceptionClass );
169
169
$ this ->expectExceptionMessage ($ exceptionMsg );
@@ -224,12 +224,12 @@ public function testSetPropertyDoesNotThrowErrorOnInvalidPropertyWhenSetForCateg
224
224
*/
225
225
public function testDirectCallWithNewArrayFormatSetsProperty ()
226
226
{
227
- $ name = 'SetPropertyAllowedAsDeclared ' ;
228
- $ sniffCode = "Fixtures.Category . {$ name }" ;
229
- $ sniffClass = 'Fixtures\Sniffs\Category \\' .$ name .'Sniff ' ;
227
+ $ name = 'AllowedAsDeclared ' ;
228
+ $ sniffCode = "Fixtures.SetProperty . {$ name }" ;
229
+ $ sniffClass = 'Fixtures\Sniffs\SetProperty \\' .$ name .'Sniff ' ;
230
230
231
231
// Set up the ruleset.
232
- $ standard = __DIR__ ."/ {$ name }Test.xml " ;
232
+ $ standard = __DIR__ ."/SetProperty {$ name }Test.xml " ;
233
233
$ config = new Config (["--standard= $ standard " ]);
234
234
$ ruleset = new Ruleset ($ config );
235
235
@@ -275,12 +275,12 @@ public function testDirectCallWithNewArrayFormatSetsProperty()
275
275
*/
276
276
public function testDirectCallWithOldArrayFormatSetsProperty ($ propertyValue )
277
277
{
278
- $ name = 'SetPropertyAllowedAsDeclared ' ;
279
- $ sniffCode = "Fixtures.Category . {$ name }" ;
280
- $ sniffClass = 'Fixtures\Sniffs\Category \\' .$ name .'Sniff ' ;
278
+ $ name = 'AllowedAsDeclared ' ;
279
+ $ sniffCode = "Fixtures.SetProperty . {$ name }" ;
280
+ $ sniffClass = 'Fixtures\Sniffs\SetProperty \\' .$ name .'Sniff ' ;
281
281
282
282
// Set up the ruleset.
283
- $ standard = __DIR__ ."/ {$ name }Test.xml " ;
283
+ $ standard = __DIR__ ."/SetProperty {$ name }Test.xml " ;
284
284
$ config = new Config (["--standard= $ standard " ]);
285
285
$ ruleset = new Ruleset ($ config );
286
286
@@ -313,34 +313,40 @@ public function testDirectCallWithOldArrayFormatSetsProperty($propertyValue)
313
313
*
314
314
* @see self::testDirectCallWithOldArrayFormatSetsProperty()
315
315
*
316
- * @return array
316
+ * @return array<string, array<string, mixed>>
317
317
*/
318
318
public static function dataDirectCallWithOldArrayFormatSetsProperty ()
319
319
{
320
320
return [
321
- 'Property value is not an array (boolean) ' => [false ],
322
- 'Property value is not an array (string) ' => ['a string ' ],
323
- 'Property value is an empty array ' => [[]],
321
+ 'Property value is not an array (boolean) ' => [
322
+ 'propertyValue ' => false ,
323
+ ],
324
+ 'Property value is not an array (string) ' => [
325
+ 'propertyValue ' => 'a string ' ,
326
+ ],
327
+ 'Property value is an empty array ' => [
328
+ 'propertyValue ' => [],
329
+ ],
324
330
'Property value is an array without keys ' => [
325
- [
331
+ ' propertyValue ' => [
326
332
'value ' ,
327
333
false ,
328
334
],
329
335
],
330
336
'Property value is an array without the "scope" or "value" keys ' => [
331
- [
337
+ ' propertyValue ' => [
332
338
'key1 ' => 'value ' ,
333
339
'key2 ' => false ,
334
340
],
335
341
],
336
342
'Property value is an array without the "scope" key ' => [
337
- [
343
+ ' propertyValue ' => [
338
344
'key1 ' => 'value ' ,
339
345
'value ' => true ,
340
346
],
341
347
],
342
348
'Property value is an array without the "value" key ' => [
343
- [
349
+ ' propertyValue ' => [
344
350
'scope ' => 'value ' ,
345
351
'key2 ' => 1234 ,
346
352
],
@@ -376,12 +382,12 @@ public function testDirectCallWithOldArrayFormatThrowsDeprecationNotice()
376
382
$ this ->setExpectedException ($ exceptionClass , $ exceptionMsg );
377
383
}
378
384
379
- $ name = 'SetPropertyAllowedAsDeclared ' ;
380
- $ sniffCode = "Fixtures.Category . {$ name }" ;
381
- $ sniffClass = 'Fixtures\Sniffs\Category \\' .$ name .'Sniff ' ;
385
+ $ name = 'AllowedAsDeclared ' ;
386
+ $ sniffCode = "Fixtures.SetProperty . {$ name }" ;
387
+ $ sniffClass = 'Fixtures\Sniffs\SetProperty \\' .$ name .'Sniff ' ;
382
388
383
389
// Set up the ruleset.
384
- $ standard = __DIR__ ."/ {$ name }Test.xml " ;
390
+ $ standard = __DIR__ ."/SetProperty {$ name }Test.xml " ;
385
391
$ config = new Config (["--standard= $ standard " ]);
386
392
$ ruleset = new Ruleset ($ config );
387
393
0 commit comments