@@ -14,6 +14,8 @@ require_once __DIR__.'/autoload.php.dist';
14
14
15
15
use Symfony \Component \Finder \Finder ;
16
16
17
+ $ fix = isset ($ argv [1 ]) && 'fix ' == $ argv [1 ];
18
+
17
19
$ finder = new Finder ();
18
20
$ finder
19
21
->files ()
@@ -24,14 +26,14 @@ $finder
24
26
->name ('*.xml ' )
25
27
->name ('*.xml.dist ' )
26
28
->name ('*.yml ' )
27
- ->in (__DIR__ )
29
+ ->in (__DIR__ . ' /src ' , __DIR__ . ' /tests ' )
28
30
->notName (basename (__FILE__ ))
29
31
->exclude ('.git ' )
30
32
->exclude ('vendor ' )
31
33
;
32
34
33
- foreach ( $ finder as $ file ) { /* @var $file Symfony\Component\Finder\SplFileInfo */
34
-
35
+ $ exit = 0 ;
36
+ foreach ( $ finder as $ file ) {
35
37
// These files are skipped because tests would break
36
38
if (in_array ($ file ->getRelativePathname (), array (
37
39
'tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.php ' ,
@@ -55,7 +57,7 @@ foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo
55
57
56
58
// [Structure] Indentation is done by steps of four spaces (tabs are never allowed);
57
59
$ new = preg_replace_callback ('/^( *)(\t+)/m ' , function ($ matches ) use ($ new ) {
58
- return $ matches [1 ] . str_repeat (' ' , strlen ($ matches [2 ]));
60
+ return $ matches [1 ]. str_repeat (' ' , strlen ($ matches [2 ]));
59
61
}, $ new );
60
62
61
63
// [Structure] Use the linefeed character (0x0A) to end lines;
@@ -68,7 +70,13 @@ foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo
68
70
$ new = preg_replace ('/([^ {|\n]$)(\n return .+?$\n \}$)/m ' , '$1 ' ."\n" .'$2 ' , $ new );
69
71
70
72
if ($ new != $ old ) {
71
- file_put_contents ($ file ->getRealpath (), $ new );
72
- echo $ file ->getRelativePathname () . PHP_EOL ;
73
+ $ exit = 1 ;
74
+ if ($ fix ) {
75
+ file_put_contents ($ file ->getRealpath (), $ new );
76
+ }
77
+
78
+ echo $ file ->getRelativePathname ().PHP_EOL ;
73
79
}
74
80
}
81
+
82
+ exit ($ exit );
0 commit comments