File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed
Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 227227 <rule ref =" Squiz.WhiteSpace.SuperfluousWhitespace.BeforeCloseBrace" >
228228 <severity >5</severity >
229229 </rule >
230+ <rule ref =" Generic.Files.EndFileNewline" >
231+ <severity >5</severity >
232+ </rule >
230233
231234 <rule ref =" Zend.Files.ClosingTag" />
232235
Original file line number Diff line number Diff line change 55namespace PixelFederation \CodingStandards \Tests \Functional ;
66
77use PHPUnit \Framework \TestCase ;
8+ use RuntimeException ;
89
910abstract class PhpcsTestCase extends TestCase
1011{
12+ public static function trimEndFileNewline (string $ file ): void
13+ {
14+ $ file = __DIR__ . '/ ' . $ file ;
15+ $ content = file_get_contents ($ file );
16+ if ($ content === false ) {
17+ throw new RuntimeException ('Could not read file: ' . $ file );
18+ }
19+
20+ $ trimmedContent = rtrim ($ content , "\n" );
21+
22+ file_put_contents ($ file , $ trimmedContent );
23+ }
24+
1125 public static function assertPhpcbf (
1226 string $ fileBefore ,
1327 string $ fileAfter ,
Original file line number Diff line number Diff line change @@ -30,4 +30,4 @@ public function __construct(
3030 $ this ->superNumber = $ total + $ heightDoubled ;
3131 }
3232
33- }
33+ }
Original file line number Diff line number Diff line change @@ -8,9 +8,12 @@ final class SuperfluousWhitespaceTest extends PhpcsTestCase
88{
99 public function testPhpcbfFixesWhitespaceAsExpected (): void
1010 {
11- self ::assertPhpcbf (
12- 'SuperfluousWhitespace/Bar.SuperfluousWhitespace.before.php ' ,
13- 'SuperfluousWhitespace/Bar.SuperfluousWhitespace.after.php ' ,
14- );
11+ $ fileBefore = 'SuperfluousWhitespace/Bar.SuperfluousWhitespace.before.php ' ;
12+ $ fileAfter = 'SuperfluousWhitespace/Bar.SuperfluousWhitespace.after.php ' ;
13+
14+ // Ensure no trailing newlines interfere with the comparison
15+ self ::trimEndFileNewline ($ fileBefore );
16+
17+ self ::assertPhpcbf ($ fileBefore , $ fileAfter );
1518 }
1619}
You can’t perform that action at this time.
0 commit comments