8000 made some tweaks to the check_cs script · renegare/symfony@5f8a0f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f8a0f5

Browse files
committed
made some tweaks to the check_cs script
1 parent d5cfb1c commit 5f8a0f5

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

check_cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ require_once __DIR__.'/autoload.php.dist';
1414

1515
use Symfony\Component\Finder\Finder;
1616

17+
$fix = isset($argv[1]) && 'fix' == $argv[1];
18+
1719
$finder = new Finder();
1820
$finder
1921
->files()
@@ -24,14 +26,14 @@ $finder
2426
->name('*.xml')
2527
->name('*.xml.dist')
2628
->name('*.yml')
27-
->in(__DIR__)
29+
->in(__DIR__.'/src', __DIR__.'/tests')
2830
->notName(basename(__FILE__))
2931
->exclude('.git')
3032
->exclude('vendor')
3133
;
3234

33-
foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo */
34-
35+
$exit = 0;
36+
foreach ($finder as $file) {
3537
// These files are skipped because tests would break
3638
if (in_array($file->getRelativePathname(), array(
3739
'tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.php',
@@ -55,7 +57,7 @@ foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo
5557

5658
// [Structure] Indentation is done by steps of four spaces (tabs are never allowed);
5759
$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]));
5961
}, $new);
6062

6163
// [Structure] Use the linefeed character (0x0A) to end lines;
@@ -68,7 +70,13 @@ foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo
6870
$new = preg_replace('/([^ {|\n]$)(\n return .+?$\n \}$)/m', '$1'."\n".'$2', $new);
6971

7072
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;
7379
}
7480
}
81+
82+
exit($exit);

0 commit comments

Comments
 (0)
0