From d5b888643b47dfc1b9e028f1471bf46c384ca6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 15 Jan 2026 16:29:37 +0400 Subject: [PATCH 1/4] configs + deps --- .github/workflows/rector-cs.yml | 27 +++++++++++ .github/workflows/rector.yml | 24 ---------- .gitignore | 4 ++ .php-cs-fixer.dist.php | 34 +++++++++++++ .styleci.yml | 85 --------------------------------- composer.json | 1 + rector.php | 2 +- 7 files changed, 67 insertions(+), 110 deletions(-) create mode 100644 .github/workflows/rector-cs.yml delete mode 100644 .github/workflows/rector.yml create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .styleci.yml diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml new file mode 100644 index 0000000..2be4d4e --- /dev/null +++ b/.github/workflows/rector-cs.yml @@ -0,0 +1,27 @@ +name: Rector + PHP CS Fixer + +on: + pull_request_target: + paths: + - 'src/**' + - 'tests/**' + - '.github/workflows/rector-cs.yml' + - 'composer.json' + - 'rector.php' + - '.php-cs-fixer.dist.php' + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + rector: + uses: yiisoft/actions/.github/workflows/rector-cs.yml@master + secrets: + token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + php: '7.4' diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml deleted file mode 100644 index 20f7d89..0000000 --- a/.github/workflows/rector.yml +++ /dev/null @@ -1,24 +0,0 @@ -on: - pull_request_target: - paths-ignore: - - 'docs/**' - - 'README.md' - - 'CHANGELOG.md' - - '.gitignore' - - '.gitattributes' - - 'infection.json.dist' - - 'psalm.xml' - -name: rector - -jobs: - rector: - uses: yiisoft/actions/.github/workflows/rector.yml@master - secrets: - token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - os: >- - ['ubuntu-latest'] - php: >- - ['8.5'] diff --git a/.gitignore b/.gitignore index 56da114..272c008 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ phpunit.phar /phpunit.xml # phpunit cache .phpunit.result.cache + +# PHP CS Fixer +/.php-cs-fixer.cache +/.php-cs-fixer.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..e9cea90 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,34 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', +]); + +return (new Config()) + ->setRiskyAllowed(true) + ->setParallelConfig(ParallelConfigFactory::detect()) + ->setRules([ + '@PER-CS3.0' => true, + 'no_unused_imports' => true, + 'ordered_class_elements' => true, + 'class_attributes_separation' => ['elements' => ['method' => 'one']], + 'declare_strict_types' => true, + 'native_function_invocation' => true, + 'native_constant_invocation' => true, + 'fully_qualified_strict_types' => [ + 'import_symbols' => true + ], + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => true, + 'import_functions' => true, + ], + ]) + ->setFinder($finder); diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 1ab379b..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,85 +0,0 @@ -preset: psr12 -risky: true - -version: 8.1 - -finder: - exclude: - - docs - - vendor - -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 - - hash_to_slash_comment - - is_null - - logical_operators - - 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_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 - - empty_loop_body_braces - - integer_literal_case - - union_type_without_spaces - -disabled: - - function_declaration diff --git a/composer.json b/composer.json index 63cb41f..919c95c 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ }, "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", + "friendsofphp/php-cs-fixer": "^3.92", "maglnet/composer-require-checker": "^3.8 || ^4.3", "phpunit/phpunit": "^9.6.22", "rector/rector": "^2.0.10", diff --git a/rector.php b/rector.php index 39f1980..d545deb 100644 --- a/rector.php +++ b/rector.php @@ -11,7 +11,7 @@ __DIR__ . '/src', __DIR__ . '/tests', ]) - ->withPhpSets(php74: true) + ->withPhp74Sets() ->withRules([ InlineConstructorDefaultToPropertyRector::class, ]) From 9390b1bf5947b439fdd3c017a4b6bc5808769b7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 15 Jan 2026 16:30:58 +0400 Subject: [PATCH 2/4] fix CS --- src/ContentDispositionHeader.php | 2 +- src/HeaderValueHelper.php | 15 +++++++++------ tests/HeaderValueHelperTest.php | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ContentDispositionHeader.php b/src/ContentDispositionHeader.php index 5a4662a..a1ef591 100644 --- a/src/ContentDispositionHeader.php +++ b/src/ContentDispositionHeader.php @@ -62,7 +62,7 @@ public static function value(string $type, ?string $fileName = null): string { if (!in_array($type, [self::INLINE, self::ATTACHMENT])) { throw new InvalidArgumentException( - 'Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".' + 'Disposition type must be either "' . self::ATTACHMENT . '" or "' . self::INLINE . '".', ); } diff --git a/src/HeaderValueHelper.php b/src/HeaderValueHelper.php index 0087142..b0f8ac9 100644 --- a/src/HeaderValueHelper.php +++ b/src/HeaderValueHelper.php @@ -28,6 +28,9 @@ use function trim; use function usort; +use const PREG_SPLIT_NO_EMPTY; +use const SORT_STRING; + /** * `HeaderValueHelper` parses the header value parameters. * @@ -78,7 +81,7 @@ public static function getValueAndParameters( string $headerValue, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true + bool $lowerCaseParameterValue = true, ): array { $headerValue = trim($headerValue); @@ -113,7 +116,7 @@ public static function getValueAndParameters( public static function getParameters( string $headerValueParameters, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true + bool $lowerCaseParameterValue = true, ): array { $headerValueParameters = trim($headerValueParameters); @@ -159,7 +162,7 @@ static function (array $matches) use (&$output, $lowerCaseParameter, $lowerCaseP }, $headerValueParameters, 1, - $count + $count, ); if ($count !== 1) { @@ -192,7 +195,7 @@ public static function getSortedValueAndParameters( $values, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true + bool $lowerCaseParameterValue = true, ): array { /** @var mixed $values Don't trust to annotations. */ @@ -223,7 +226,7 @@ public static function getSortedValueAndParameters( $value, $lowerCaseValue, $lowerCaseParameter, - $lowerCaseParameterValue + $lowerCaseParameterValue, ); // case-insensitive "q" parameter $q = $parse['q'] ?? $parse['Q'] ?? 1.0; @@ -242,7 +245,7 @@ public static function getSortedValueAndParameters( $output, static function (array $a, array $b) { return $b['q'] <=> $a['q']; - } + }, ); return $output; diff --git a/tests/HeaderValueHelperTest.php b/tests/HeaderValueHelperTest.php index c78a207..92b87f2 100644 --- a/tests/HeaderValueHelperTest.php +++ b/tests/HeaderValueHelperTest.php @@ -225,7 +225,7 @@ public function testGetParameters( ?bool $lowerCaseParameter, ?bool $lowerCaseValue, ?array $expected, - ?string $expectedException = null + ?string $expectedException = null, ): void { if ($expectedException !== null) { $this->expectException($expectedException); From 28354ff907e500142531d778d2e674b4d2ac355b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 15 Jan 2026 16:31:52 +0400 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75dc718..080b2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.3.1 under development -- no changes in this release. +- Enh #62: Explicitly import constants in "use" section (@mspirkov) ## 1.3.0 November 25, 2025 From 28881a51c6125a651f164aa9d7dc8401d754f67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 15 Jan 2026 16:36:30 +0400 Subject: [PATCH 4/4] fix for 7.4 --- src/HeaderValueHelper.php | 6 +++--- tests/HeaderValueHelperTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HeaderValueHelper.php b/src/HeaderValueHelper.php index b0f8ac9..dffc2a5 100644 --- a/src/HeaderValueHelper.php +++ b/src/HeaderValueHelper.php @@ -81,7 +81,7 @@ public static function getValueAndParameters( string $headerValue, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true, + bool $lowerCaseParameterValue = true ): array { $headerValue = trim($headerValue); @@ -116,7 +116,7 @@ public static function getValueAndParameters( public static function getParameters( string $headerValueParameters, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true, + bool $lowerCaseParameterValue = true ): array { $headerValueParameters = trim($headerValueParameters); @@ -195,7 +195,7 @@ public static function getSortedValueAndParameters( $values, bool $lowerCaseValue = true, bool $lowerCaseParameter = true, - bool $lowerCaseParameterValue = true, + bool $lowerCaseParameterValue = true ): array { /** @var mixed $values Don't trust to annotations. */ diff --git a/tests/HeaderValueHelperTest.php b/tests/HeaderValueHelperTest.php index 92b87f2..c78a207 100644 --- a/tests/HeaderValueHelperTest.php +++ b/tests/HeaderValueHelperTest.php @@ -225,7 +225,7 @@ public function testGetParameters( ?bool $lowerCaseParameter, ?bool $lowerCaseValue, ?array $expected, - ?string $expectedException = null, + ?string $expectedException = null ): void { if ($expectedException !== null) { $this->expectException($expectedException);