fixed root search path to include only './src' and './tests'

This commit is contained in:
Brikou CARRE 2011-06-08 18:11:05 +02:00
parent 3d5a96ef98
commit cd2a7bb2be
1 changed files with 13 additions and 9 deletions

View File

@ -26,19 +26,20 @@ $finder
->name('*.xml') ->name('*.xml')
->name('*.xml.dist') ->name('*.xml.dist')
->name('*.yml') ->name('*.yml')
->in(__DIR__) ->in(array(__DIR__.'/src', __DIR__.'/tests'))
->notName(basename(__FILE__)) ->notName(basename(__FILE__))
->exclude('.git') ->exclude('.git')
->exclude('vendor') ->exclude('vendor')
; ;
$exit = 0; $count = 0;
foreach ($finder as $file) { foreach ($finder as $file) {
/* @var $file Symfony\Component\Finder\SplFileInfo */ /* @var $file Symfony\Component\Finder\SplFileInfo */
// These files are skipped because tests would break // These files are skipped because tests would break
if (in_array($file->getRelativePathname(), array( foreach(array(
'tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.php', 'tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.php',
'tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php', 'tests/Symfony/Tests/Component/DependencyInjection/Fixtures/containers/container9.php',
'tests/Symfony/Tests/Component/DependencyInjection/Fixtures/includes/foo.php', 'tests/Symfony/Tests/Component/DependencyInjection/Fixtures/includes/foo.php',
@ -47,8 +48,11 @@ foreach ($finder as $file) {
'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher1.php', 'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher1.php',
'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher2.php', 'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher2.php',
'tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml', 'tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml',
))) { ) as $skippedFile) {
continue;
if ($skippedFile === substr($file->getRealPath(), strlen($skippedFile) * -1)) {
continue(2);
}
} }
$old = file_get_contents($file->getRealpath()); $old = file_get_contents($file->getRealpath());
@ -90,13 +94,13 @@ foreach ($finder as $file) {
} }
if ($new != $old) { if ($new != $old) {
$exit = 1; $count++;
if ($fix) { if ($fix) {
file_put_contents($file->getRealpath(), $new); file_put_contents($file->getRealpath(), $new);
} }
printf('%4d) %s'.PHP_EOL, $count, $file->getRelativePathname());
echo $file->getRelativePathname().PHP_EOL;
} }
} }
exit($exit); exit($count ? 1 : 0);