From 5375fad0c5dbf6935f26f472efa5305c213220bc Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 9 Oct 2026 21:30:38 +0400 Subject: [PATCH 1/2] ci: add spiral/code-style with php-cs-fixer Replaces the StyleCI config. Assisted-By: Claude Opus 5.5 --- .github/workflows/cs-fix.yml | 17 +++++++++ .gitignore | 3 ++ .php-cs-fixer.dist.php | 13 +++++++ .styleci.yml | 73 ------------------------------------ composer.json | 3 ++ 5 files changed, 36 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/cs-fix.yml create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .styleci.yml diff --git a/.github/workflows/cs-fix.yml b/.github/workflows/cs-fix.yml new file mode 100644 index 0000000..93c780e --- /dev/null +++ b/.github/workflows/cs-fix.yml @@ -0,0 +1,17 @@ +--- + +on: # yamllint disable-line rule:truthy + push: + branches: + - '**' + +name: Fix Code Style + +jobs: + cs-fix: + permissions: + contents: write + uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master + with: + php: >- + ['8.4'] diff --git a/.gitignore b/.gitignore index 008a742..cb52aae 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ Thumbs.db clover.xml .env builds + +# Runtime +runtime/ diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..45745a1 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,13 @@ +include(__DIR__ . '/src') + ->include(__DIR__ . '/tests') + ->include(__FILE__) + ->cache('./runtime/php-cs-fixer.cache') + ->allowRisky(false) + ->build(); diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 6fde134..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,73 +0,0 @@ -preset: psr12 -risky: true - -version: 8 - -enabled: - - alpha_ordered_traits - - array_indentation - - array_push - - combine_consecutive_issets - - combine_consecutive_unsets - - combine_nested_dirname - - declare_strict_types - - dir_constant - - fully_qualified_strict_types - - function_to_constant - - is_null - - magic_constant_casing - - magic_method_casing - - method_separation - - modernize_types_casting - - native_function_casing - - native_function_type_declaration_casing - - no_alias_functions - - no_empty_comment - - no_empty_phpdoc - - no_empty_statement - - no_extra_block_blank_lines - - no_short_bool_cast - - no_superfluous_elseif - - no_unneeded_control_parentheses - - no_unneeded_curly_braces - - no_unneeded_final_method - - no_unset_cast - - no_unused_imports - - no_unused_lambda_imports - - no_useless_else - - no_useless_return - - normalize_index_brace - - php_unit_dedicate_assert - - php_unit_dedicate_assert_internal_type - - php_unit_expectation - - php_unit_mock - - php_unit_mock_short_will_return - - php_unit_namespaced - - php_unit_no_expectation_annotation - - phpdoc_no_empty_return - - phpdoc_no_useless_inheritdoc - - phpdoc_order - - phpdoc_property - - phpdoc_scalar - - phpdoc_separation - - phpdoc_singular_inheritdoc - - phpdoc_trim - - phpdoc_trim_consecutive_blank_line_separation - - phpdoc_type_to_var - - phpdoc_types - - phpdoc_types_order - - print_to_echo - - regular_callable_call - - return_assignment - - self_accessor - - self_static_accessor - - set_type_to_cast - - short_array_syntax - - short_list_syntax - - simplified_if_return - - single_quote - - standardize_not_equals - - ternary_to_null_coalescing - - trailing_comma_in_multiline_array - - unalign_double_arrow - - unalign_equals diff --git a/composer.json b/composer.json index 499750d..e1dceef 100644 --- a/composer.json +++ b/composer.json @@ -49,6 +49,7 @@ "require-dev": { "mockery/mockery": "^1.5", "phpunit/phpunit": "^10.0", + "spiral/code-style": "^2.3.1", "vimeo/psalm": ">=5.8" }, "autoload-dev": { @@ -57,6 +58,8 @@ } }, "scripts": { + "cs:diff": "php-cs-fixer fix --dry-run -v --diff", + "cs:fix": "php-cs-fixer fix -v", "tests": "phpunit", "psalm": "psalm --no-cache" }, From 803bbca98f2b4787a5d92af5cf9872c4b75ca00b Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 9 Oct 2026 21:30:43 +0400 Subject: [PATCH 2/2] style: apply spiral/code-style Assisted-By: Claude Opus 5.5 --- src/Exception/ServiceException.php | 5 +---- src/Manager.php | 4 ++-- tests/ManagerTest.php | 36 +++++++++++++++--------------- tests/TestCase.php | 5 +---- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/Exception/ServiceException.php b/src/Exception/ServiceException.php index 2f8358b..1785be6 100644 --- a/src/Exception/ServiceException.php +++ b/src/Exception/ServiceException.php @@ -4,7 +4,4 @@ namespace Spiral\RoadRunner\Services\Exception; -class ServiceException extends \Exception -{ - -} +class ServiceException extends \Exception {} diff --git a/src/Manager.php b/src/Manager.php index 91fed1a..c0d32d0 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -75,7 +75,7 @@ public function create( array $env = [], int $restartSec = 30, bool $serviceNameInLogs = false, - int $stopTimeout = 5 + int $stopTimeout = 5, ): bool { \assert($processNum > 0, 'Process number must be greater than 0.'); \assert($execTimeout >= 0, 'Execution timeout must be greater or equal to 0.'); @@ -181,7 +181,7 @@ public function statuses(string $name): array $error = [ 'code' => $statusError->getCode(), 'message' => $statusError->getMessage(), - 'details' => \array_map(static fn (Any $any) => [ + 'details' => \array_map(static fn(Any $any) => [ 'message' => $any->getValue(), 'type_url' => $any->getTypeUrl(), ], \iterator_to_array($statusError->getDetails()->getIterator())), diff --git a/tests/ManagerTest.php b/tests/ManagerTest.php index 7799252..27c3469 100644 --- a/tests/ManagerTest.php +++ b/tests/ManagerTest.php @@ -22,21 +22,6 @@ final class ManagerTest extends TestCase private Manager $manager; private m\LegacyMockInterface|m\MockInterface|RPCInterface $rpc; - protected function setUp(): void - { - parent::setUp(); - - $this->rpc = m::mock(RPCInterface::class); - - $this->rpc - ->shouldReceive('withCodec') - ->once() - ->withArgs(static fn($codec): bool => $codec instanceof ProtobufCodec) - ->andReturnSelf(); - - $this->manager = new Manager($this->rpc); - } - public function testListServices(): void { $this->rpc @@ -96,8 +81,8 @@ public function testServiceShouldBeCreated(): void ['FOO' => 'bar', 'BAZ' => 'foo'], 50, true, - 10 - ) + 10, + ), ); } @@ -197,7 +182,7 @@ public function testServiceStatusesShouldBeReturned(): void ]), ]), ], - ]) + ]), ); $status = $this->manager->statuses('foo'); @@ -218,4 +203,19 @@ public function testServiceStatusesShouldBeReturned(): void ], ], $status); } + + protected function setUp(): void + { + parent::setUp(); + + $this->rpc = m::mock(RPCInterface::class); + + $this->rpc + ->shouldReceive('withCodec') + ->once() + ->withArgs(static fn($codec): bool => $codec instanceof ProtobufCodec) + ->andReturnSelf(); + + $this->manager = new Manager($this->rpc); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index fb1f490..bd03acd 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,7 +6,4 @@ use PHPUnit\Framework\TestCase as BaseTestCase; -abstract class TestCase extends BaseTestCase -{ - -} +abstract class TestCase extends BaseTestCase {}