#!/usr/bin/env php files() ->name('*.md') ->name('*.php') ->name('*.php.dist') ->name('*.twig') ->name('*.xml') ->name('*.xml.dist') ->name('*.yml') ->in(__DIR__.'/src') ->notName(basename(__FILE__)) ->exclude('.git') ->exclude('vendor') ; // These files are skipped because tests would break $skippedFiles = array_map('realpath', array( 'src/Symfony/Component/Yaml/Tests/Fixtures/sfTests.yml', )); $count = 0; foreach ($finder as $file) { /* @var $file Symfony\Component\Finder\SplFileInfo */ $path = $file->getRealPath(); if (in_array($path, $skippedFiles)) { continue; } $old = file_get_contents($path); $new = $old; // [Structure] Never use short tags (getExtension()) { $new = preg_replace('/} else if \(/', '} elseif (', $new); } if ($new != $old) { $count++; if ($fix) { file_put_contents($path, $new); } printf('%4d) %s'.PHP_EOL, $count, $file->getRelativePathname()); } } exit($count ? 1 : 0);