diff --git a/src/Console/Command/ListFilesCommand.php b/src/Console/Command/ListFilesCommand.php index ae2a1c0f756..36fe03b2d96 100644 --- a/src/Console/Command/ListFilesCommand.php +++ b/src/Console/Command/ListFilesCommand.php @@ -20,7 +20,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Finder\SplFileInfo as sfSplFileInfo; use SplFileInfo; /** @@ -68,6 +67,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $passedConfig = $input->getOption('config'); + $cwd = getcwd(); $resolver = new ConfigurationResolver( $this->defaultConfig, @@ -80,16 +80,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $finder = $resolver->getFinder(); - /** @var SplFileInfo|sfSplFileInfo $file */ + /** @var SplFileInfo $file */ foreach ($finder as $file) { - if ($file instanceof sfSplFileInfo) { - if ($file->isFile()) { - $output->writeln(escapeshellarg($file->getRelativePathname())); - } - } else if ($file instanceof SplFileInfo) { - if ($file->isFile()) { - $output->writeln(escapeshellarg($file->getPathname())); - } + if ($file->isFile()) { + $relativePath = str_replace($cwd, '.', $file->getPathname()); + $output->writeln(escapeshellarg($relativePath)); } } diff --git a/tests/Console/Command/ListFilesCommandTest.php b/tests/Console/Command/ListFilesCommandTest.php index 9f7f9d5e0bc..76bdafc4335 100644 --- a/tests/Console/Command/ListFilesCommandTest.php +++ b/tests/Console/Command/ListFilesCommandTest.php @@ -30,7 +30,7 @@ public function testListWithConfig() $commandTester = $this->doTestExecute([ '--config' => __DIR__ . '/../../Fixtures/ListFilesTest/.php-cs-fixer.php' ]); - $this->assertSame(escapeshellarg('needs-fixing/needs-fixing.php').PHP_EOL, $commandTester->getDisplay()); + $this->assertSame(escapeshellarg('./tests/Fixtures/ListFilesTest/needs-fixing/needs-fixing.php').PHP_EOL, $commandTester->getDisplay()); } /**