merged branch Ringosan/check_cs_fixes (PR #4263)

Commits
-------

0bcc5fa [check_cs] Fixed and optimized the coding standard script

Discussion
----------

[check_cs] Fixed and optimized the coding standard script

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: ~
Todo: ~
License of the code: MIT
Documentation PR: ~

Minor optimizations and fixes for the coding standard script. Fixes paths to skipped files which have now been moved.

[check_cs] Optimized coding standards script

* Defined skipped files array outside of foreach loop
* Reduced calls to $file->getRealPath() to one

[check_cs] Fixed skipped file paths

Paths to skipped files have changed since test files have been moved
into individual components

[check_cs] Optimized coding standards script

* Removed nested foreach loop

[check_cs] Minor formatting change

---------------------------------------------------------------------------

by travisbot at 2012-05-11T15:46:18Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1306159) (merged 0bcc5fa2 into 554e0738).
This commit is contained in:
Fabien Potencier 2012-05-11 18:03:46 +02:00
commit 9f3c3ec1df

View File

@ -28,35 +28,35 @@ $finder
->name('*.yml')
->in(__DIR__.'/src')
->notName(basename(__FILE__))
->notName('sfTests.yml')
->exclude('.git')
->exclude('vendor')
;
// These files are skipped because tests would break
$skippedFiles = array_map('realpath', array(
'src/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php',
'src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php',
'src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/foo.php',
'src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php',
'src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml',
'src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php',
'src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php',
'src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml',
));
$count = 0;
foreach ($finder as $file) {
/* @var $file Symfony\Component\Finder\SplFileInfo */
// These files are skipped because tests would break
foreach(array(
'tests/Symfony/Tests/Component/ClassLoader/ClassCollectionLoaderTest.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/php/services9.php',
'tests/Symfony/Tests/Component/DependencyInjection/Fixtures/yaml/services9.yml',
'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher1.php',
'tests/Symfony/Tests/Component/Routing/Fixtures/dumper/url_matcher2.php',
'tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml',
) as $skippedFile) {
$path = $file->getRealPath();
if ($skippedFile === substr($file->getRealPath(), strlen($skippedFile) * -1)) {
continue(2);
}
if (in_array($path, $skippedFiles)) {
continue;
}
$old = file_get_contents($file->getRealpath());
$old = file_get_contents($path);
$new = $old;
@ -103,7 +103,7 @@ foreach ($finder as $file) {
$count++;
if ($fix) {
file_put_contents($file->getRealpath(), $new);
file_put_contents($path, $new);
}
printf('%4d) %s'.PHP_EOL, $count, $file->getRelativePathname());
}