diff --git a/src/PhpGitHooks/Module/PhpCsFixer/Contract/Command/PhpCsFixerToolHandler.php b/src/PhpGitHooks/Module/PhpCsFixer/Contract/Command/PhpCsFixerToolHandler.php index a4caf4a..8dd53e7 100644 --- a/src/PhpGitHooks/Module/PhpCsFixer/Contract/Command/PhpCsFixerToolHandler.php +++ b/src/PhpGitHooks/Module/PhpCsFixer/Contract/Command/PhpCsFixerToolHandler.php @@ -45,19 +45,19 @@ public function __construct(OutputInterface $output, PhpCsFixerToolProcessorInte private function execute(array $files, $psr0, $psr1, $psr2, $symfony, $options, $errorMessage) { if (true === $psr0) { - $this->executeTool($files, 'PSR0', $options, $errorMessage); + $this->executeTool($files, '@PSR0', $options, $errorMessage); } if (true === $psr1) { - $this->executeTool($files, 'PSR1', $options, $errorMessage); + $this->executeTool($files, '@PSR1', $options, $errorMessage); } if (true === $psr2) { - $this->executeTool($files, 'PSR2', $options, $errorMessage); + $this->executeTool($files, '@PSR2', $options, $errorMessage); } if (true === $symfony) { - $this->executeTool($files, 'SYMFONY', $options, $errorMessage); + $this->executeTool($files, '@Symfony', $options, $errorMessage); } } @@ -71,7 +71,9 @@ private function execute(array $files, $psr0, $psr1, $psr2, $symfony, $options, */ private function executeTool(array $files, $level, $options, $errorMessage) { - $outputMessage = new PreCommitOutputWriter(sprintf('Checking %s code style with PHP-CS-FIXER', $level)); + $outputMessage = new PreCommitOutputWriter( + sprintf('Checking %s code style with PHP-CS-FIXER', str_replace('@', '', $level)) + ); $this->output->write($outputMessage->getMessage()); $errors = []; diff --git a/src/PhpGitHooks/Module/PhpCsFixer/Infrastructure/Tool/PhpCsFixerToolProcessor.php b/src/PhpGitHooks/Module/PhpCsFixer/Infrastructure/Tool/PhpCsFixerToolProcessor.php index 133e14d..2a50578 100644 --- a/src/PhpGitHooks/Module/PhpCsFixer/Infrastructure/Tool/PhpCsFixerToolProcessor.php +++ b/src/PhpGitHooks/Module/PhpCsFixer/Infrastructure/Tool/PhpCsFixerToolProcessor.php @@ -49,10 +49,10 @@ private function processTool($file, $level, $options) $arguments = [ 'php', $this->toolPathFinder->find('php-cs-fixer'), - '--dry-run', 'fix', $file, - '--level='.$level, + '--dry-run', + '--rules='.$level, ]; if (null !== $options) { diff --git a/src/PhpGitHooks/Module/PhpCsFixer/Tests/Behaviour/PhpCsFixerToolHandlerTest.php b/src/PhpGitHooks/Module/PhpCsFixer/Tests/Behaviour/PhpCsFixerToolHandlerTest.php index 5d7c4f0..ff8ea5b 100644 --- a/src/PhpGitHooks/Module/PhpCsFixer/Tests/Behaviour/PhpCsFixerToolHandlerTest.php +++ b/src/PhpGitHooks/Module/PhpCsFixer/Tests/Behaviour/PhpCsFixerToolHandlerTest.php @@ -44,7 +44,7 @@ public function itShouldThrowsException() $errors = null; foreach ($phpFiles as $file) { $errorText = 'ERROR'; - $this->shouldProcessPhpCsFixerTool($file, 'PSR0', $phpCsFixerOptions->value(), $errorText); + $this->shouldProcessPhpCsFixerTool($file, '@PSR0', $phpCsFixerOptions->value(), $errorText); $errors .= $errorText; } @@ -78,7 +78,7 @@ public function itShouldWorksFine() $this->shouldWriteOutput($outputMessagePsr0->getMessage()); foreach ($phpFiles as $file) { - $this->shouldProcessPhpCsFixerTool($file, 'PSR0', $phpCsFixerOptions->value(), null); + $this->shouldProcessPhpCsFixerTool($file, '@PSR0', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr0->getSuccessfulMessage()); @@ -87,7 +87,7 @@ public function itShouldWorksFine() $this->shouldWriteOutput($outputMessagePsr1->getMessage()); foreach ($phpFiles as $file) { - $this->shouldProcessPhpCsFixerTool($file, 'PSR1', $phpCsFixerOptions->value(), null); + $this->shouldProcessPhpCsFixerTool($file, '@PSR1', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr1->getSuccessfulMessage()); @@ -96,16 +96,16 @@ public function itShouldWorksFine() $this->shouldWriteOutput($outputMessagePsr2->getMessage()); foreach ($phpFiles as $file) { - $this->shouldProcessPhpCsFixerTool($file, 'PSR2', $phpCsFixerOptions->value(), null); + $this->shouldProcessPhpCsFixerTool($file, '@PSR2', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessagePsr2->getSuccessfulMessage()); - $outputMessageSymfony = new PreCommitOutputWriter('Checking SYMFONY code style with PHP-CS-FIXER'); + $outputMessageSymfony = new PreCommitOutputWriter('Checking Symfony code style with PHP-CS-FIXER'); $this->shouldWriteOutput($outputMessageSymfony->getMessage()); foreach ($phpFiles as $file) { - $this->shouldProcessPhpCsFixerTool($file, 'SYMFONY', $phpCsFixerOptions->value(), null); + $this->shouldProcessPhpCsFixerTool($file, '@Symfony', $phpCsFixerOptions->value(), null); } $this->shouldWriteLnOutput($outputMessageSymfony->getSuccessfulMessage());