@@ -51,6 +51,16 @@ public function testSuppressError()
51
51
$ this ->assertEquals (0 , $ numErrors );
52
52
$ this ->assertCount (0 , $ errors );
53
53
54
+ // Process with multi-line inline comment suppression, tab-indented.
55
+ $ content = '<?php ' .PHP_EOL ."\t" .'// For reasons ' .PHP_EOL ."\t" .'// phpcs:disable ' .PHP_EOL ."\t" .'$var = FALSE; ' .PHP_EOL ."\t" .'// phpcs:enable ' ;
56
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
57
+ $ file ->process ();
58
+
59
+ $ errors = $ file ->getErrors ();
60
+ $ numErrors = $ file ->getErrorCount ();
61
+ $ this ->assertEquals (0 , $ numErrors );
62
+ $ this ->assertCount (0 , $ errors );
63
+
54
64
// Process with inline @ comment suppression.
55
65
$ content = '<?php ' .PHP_EOL .'// @phpcs:disable ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'// @phpcs:enable ' ;
56
66
$ file = new DummyFile ($ content , $ ruleset , $ config );
@@ -82,7 +92,37 @@ public function testSuppressError()
82
92
$ this ->assertCount (0 , $ errors );
83
93
84
94
// Process with block comment suppression.
85
- $ content = '<?php ' .PHP_EOL .'/* phpcs:disable */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/* phpcs:disable */ ' ;
95
+ $ content = '<?php ' .PHP_EOL .'/* phpcs:disable */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/* phpcs:enable */ ' ;
96
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
97
+ $ file ->process ();
98
+
99
+ $ errors = $ file ->getErrors ();
100
+ $ numErrors = $ file ->getErrorCount ();
101
+ $ this ->assertEquals (0 , $ numErrors );
102
+ $ this ->assertCount (0 , $ errors );
103
+
104
+ // Process with multi-line block comment suppression.
105
+ $ content = '<?php ' .PHP_EOL .'/* ' .PHP_EOL .' phpcs:disable ' .PHP_EOL .' */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/* ' .PHP_EOL .' phpcs:enable ' .PHP_EOL .' */ ' ;
106
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
107
+ $ file ->process ();
108
+
109
+ $ errors = $ file ->getErrors ();
110
+ $ numErrors = $ file ->getErrorCount ();
111
+ $ this ->assertEquals (0 , $ numErrors );
112
+ $ this ->assertCount (0 , $ errors );
113
+
114
+ // Process with multi-line block comment suppression, each line starred.
115
+ $ content = '<?php ' .PHP_EOL .'/* ' .PHP_EOL .' * phpcs:disable ' .PHP_EOL .' */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/* ' .PHP_EOL .' * phpcs:enable ' .PHP_EOL .' */ ' ;
116
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
117
+ $ file ->process ();
118
+
119
+ $ errors = $ file ->getErrors ();
120
+ $ numErrors = $ file ->getErrorCount ();
121
+ $ this ->assertEquals (0 , $ numErrors );
122
+ $ this ->assertCount (0 , $ errors );
123
+
124
+ // Process with multi-line block comment suppression, tab-indented.
125
+ $ content = '<?php ' .PHP_EOL ."\t" .'/* ' .PHP_EOL ."\t" .' * phpcs:disable ' .PHP_EOL ."\t" .' */ ' .PHP_EOL ."\t" .'$var = FALSE; ' .PHP_EOL ."\t" .'/* ' .PHP_EOL .' * phpcs:enable ' .PHP_EOL .' */ ' ;
86
126
$ file = new DummyFile ($ content , $ ruleset , $ config );
87
127
$ file ->process ();
88
128
@@ -101,6 +141,16 @@ public function testSuppressError()
101
141
$ this ->assertEquals (0 , $ numErrors );
102
142
$ this ->assertCount (0 , $ errors );
103
143
144
+ // Process with multi-line block comment suppression (deprecated syntax).
145
+ $ content = '<?php ' .PHP_EOL .'/* ' .PHP_EOL .' @codingStandardsIgnoreStart ' .PHP_EOL .' */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/* ' .PHP_EOL .' @codingStandardsIgnoreEnd ' .PHP_EOL .' */ ' ;
146
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
147
+ $ file ->process ();
148
+
149
+ $ errors = $ file ->getErrors ();
150
+ $ numErrors = $ file ->getErrorCount ();
151
+ $ this ->assertEquals (0 , $ numErrors );
152
+ $ this ->assertCount (0 , $ errors );
153
+
104
154
// Process with a docblock suppression.
105
155
$ content = '<?php ' .PHP_EOL .'/** phpcs:disable */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'/** phpcs:enable */ ' ;
106
156
$ file = new DummyFile ($ content , $ ruleset , $ config );
@@ -319,6 +369,26 @@ public function testSuppressLine()
319
369
$ this ->assertEquals (1 , $ numErrors );
320
370
$ this ->assertCount (1 , $ errors );
321
371
372
+ // Process with suppression on line before.
373
+ $ content = '<?php ' .PHP_EOL .'/* phpcs:ignore */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'$var = FALSE; ' ;
374
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
375
+ $ file ->process ();
376
+
377
+ $ errors = $ file ->getErrors ();
378
+ $ numErrors = $ file ->getErrorCount ();
379
+ $ this ->assertEquals (1 , $ numErrors );
380
+ $ this ->assertCount (1 , $ errors );
381
+
382
+ // Process with @ suppression on line before.
383
+ $ content = '<?php ' .PHP_EOL .'/* @phpcs:ignore */ ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'$var = FALSE; ' ;
384
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
385
+ $ file ->process ();
386
+
387
+ $ errors = $ file ->getErrors ();
388
+ $ numErrors = $ file ->getErrorCount ();
389
+ $ this ->assertEquals (1 , $ numErrors );
390
+ $ this ->assertCount (1 , $ errors );
391
+
322
392
// Process with suppression on line before (deprecated syntax).
323
393
$ content = '<?php ' .PHP_EOL .'// @codingStandardsIgnoreLine ' .PHP_EOL .'$var = FALSE; ' .PHP_EOL .'$var = FALSE; ' ;
324
394
$ file = new DummyFile ($ content , $ ruleset , $ config );
@@ -614,6 +684,16 @@ public function testSuppressFile()
614
684
$ this ->assertEquals (0 , $ numWarnings );
615
685
$ this ->assertCount (0 , $ warnings );
616
686
687
+ // Process with a multi-line block comment suppression.
688
+ $ content = '<?php ' .PHP_EOL .'/* ' .PHP_EOL .' phpcs:ignoreFile ' .PHP_EOL .' */ ' .PHP_EOL .'//TODO: write some code ' ;
689
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
690
+ $ file ->process ();
691
+
692
+ $ warnings = $ file ->getWarnings ();
693
+ $ numWarnings = $ file ->getWarningCount ();
694
+ $ this ->assertEquals (0 , $ numWarnings );
695
+ $ this ->assertCount (0 , $ warnings );
696
+
617
697
// Process with a block comment suppression (deprecated syntax).
618
698
$ content = '<?php ' .PHP_EOL .'/* @codingStandardsIgnoreFile */ ' .PHP_EOL .'//TODO: write some code ' ;
619
699
$ file = new DummyFile ($ content , $ ruleset , $ config );
@@ -624,6 +704,16 @@ public function testSuppressFile()
624
704
$ this ->assertEquals (0 , $ numWarnings );
625
705
$ this ->assertCount (0 , $ warnings );
626
706
707
+ // Process with a multi-line block comment suppression (deprecated syntax).
708
+ $ content = '<?php ' .PHP_EOL .'/* ' .PHP_EOL .' @codingStandardsIgnoreFile ' .PHP_EOL .' */ ' .PHP_EOL .'//TODO: write some code ' ;
709
+ $ file = new DummyFile ($ content , $ ruleset , $ config );
710
+ $ file ->process ();
711
+
712
+ $ warnings = $ file ->getWarnings ();
713
+ $ numWarnings = $ file ->getWarningCount ();
714
+ $ this ->assertEquals (0 , $ numWarnings );
715
+ $ this ->assertCount (0 , $ warnings );
716
+
627
717
// Process with docblock suppression.
628
718
$ content = '<?php ' .PHP_EOL .'/** phpcs:ignoreFile */ ' .PHP_EOL .'//TODO: write some code ' ;
629
719
$ file = new DummyFile ($ content , $ ruleset , $ config );
@@ -762,7 +852,7 @@ public function testDisableSelected()
762
852
$ this ->assertEquals (0 , $ numWarnings );
763
853
$ this ->assertCount (0 , $ warnings );
764
854
765
- // Suppress wrong catergory using docblocks.
855
+ // Suppress wrong category using docblocks.
766
856
$ content = '<?php ' .PHP_EOL .'/**
767
857
' .PHP_EOL .' * phpcs:disable Generic.Files ' .PHP_EOL .' */ ' .PHP_EOL .'//TODO: write some code ' ;
768
858
$ file = new DummyFile ($ content , $ ruleset , $ config );
0 commit comments