diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index 07735fc..2cc318c 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -32,6 +32,8 @@ jobs: run: composer validate --strict --no-check-lock - name: Install Composer dependencies (with dev) run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader + - name: PHP CodeSniffer + run: composer phpcs - name: PHPUnit run: composer test - name: Install Composer dependencies (without dev) diff --git a/composer.json b/composer.json index 7dc05b4..312fef6 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,11 @@ "Imponeer\\Decorators\\LogDataOutput\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Imponeer\\Decorators\\LogDataOutput\\Tests\\": "tests/" + } + }, "keywords": [ "symfony", "console", @@ -25,9 +30,12 @@ "decorator" ], "require-dev": { - "phpunit/phpunit": "^12" + "phpunit/phpunit": "^12", + "squizlabs/php_codesniffer": "^3.10" }, "scripts": { - "test": "phpunit --testdox" + "test": "phpunit --testdox", + "phpcs": "phpcs --standard=PSR12 src/ tests/", + "phpcbf": "phpcbf --standard=PSR12 src/ tests/" } } diff --git a/src/OutputDecorator.php b/src/OutputDecorator.php index 609f036..7e3ab8c 100644 --- a/src/OutputDecorator.php +++ b/src/OutputDecorator.php @@ -71,7 +71,8 @@ public function fatal(string $message, ...$params): void * * @return string */ - public function renderIndentString(): string { + public function renderIndentString(): string + { return str_repeat(' ', $this->indent * 2); } @@ -224,4 +225,4 @@ public function getFormatter(): OutputFormatterInterface { return $this->output->getFormatter(); } -} \ No newline at end of file +} diff --git a/tests/OutputDecoratorTest.php b/tests/OutputDecoratorTest.php index bfd2df7..065d6e9 100644 --- a/tests/OutputDecoratorTest.php +++ b/tests/OutputDecoratorTest.php @@ -1,5 +1,7 @@ [ 'writeln', @@ -87,7 +90,8 @@ public static function getTestData(): array { ]; } - private function useDecoratorMethod(string $method, string $text, array $params): string { + private function useDecoratorMethod(string $method, string $text, array $params): string + { if (empty($params)) { $this->decorator->$method($text); } else { @@ -99,7 +103,8 @@ private function useDecoratorMethod(string $method, string $text, array $params) } #[DataProvider('getTestData')] - public function testIncrIndent(string $method, string $text, array $args = [], ?string $shouldReturn = null): void { + public function testIncrIndent(string $method, string $text, array $args = [], ?string $shouldReturn = null): void + { if ($shouldReturn === null) { $shouldReturn = $text; } @@ -136,7 +141,8 @@ public function testDecrIndent(string $method, string $text, array $args = [], ? } #[DataProvider('getTestData')] - public function testResetIncr(string $method, string $text, array $args = [], ?string $shouldReturn = null): void { + public function testResetIncr(string $method, string $text, array $args = [], ?string $shouldReturn = null): void + { if ($shouldReturn === null) { $shouldReturn = $text; } @@ -152,5 +158,4 @@ public function testResetIncr(string $method, string $text, array $args = [], ?s $buffer = $this->useDecoratorMethod($method, $text, $args); $this->assertSame($shouldReturn . PHP_EOL, $buffer); } - -} \ No newline at end of file +}