From 40ada4599a6281ad9f95df9055f1712c821b5456 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 20 Oct 2026 12:03:27 +0300 Subject: [PATCH 1/3] Update dev tools, move caches to runtime directory and adjust CI - Bump php-cs-fixer, phpunit, rector and psalm - Move roave/infection-static-analysis-plugin to tools/infection via bamarni/composer-bin-plugin - Store PHP CS Fixer and PHPUnit caches in runtime/ - Fix concurrency groups and rector-cs job permissions in workflows - Replace composer-require-checker target in Makefile with composer-dependency-analyser --- .github/workflows/mssql.yml | 2 +- .github/workflows/mutation.yml | 1 + .github/workflows/mysql.yml | 2 +- .github/workflows/oracle.yml | 2 +- .github/workflows/pgsql.yml | 2 +- .github/workflows/rector-cs.yml | 4 +++- .github/workflows/sqlite.yml | 2 +- .gitignore | 4 ---- .php-cs-fixer.dist.php | 1 + Makefile | 4 ++-- composer.json | 20 +++++++++++++------- docker/Dockerfile | 2 +- phpunit.xml.dist | 2 +- rector.php | 2 -- runtime/.gitignore | 2 ++ tests/Base/DataTrait.php | 4 +--- tools/.gitignore | 2 ++ tools/infection/composer.json | 10 ++++++++++ 18 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 runtime/.gitignore create mode 100644 tools/.gitignore create mode 100644 tools/infection/composer.json diff --git a/.github/workflows/mssql.yml b/.github/workflows/mssql.yml index 5592c14..d06dd80 100644 --- a/.github/workflows/mssql.yml +++ b/.github/workflows/mssql.yml @@ -17,7 +17,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index fa2ba58..1725441 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -7,6 +7,7 @@ on: - 'tests/**' - 'phpunit.xml.dist' - 'infection.json.dist' + - 'tools/infection/composer.json' - 'composer.json' - '.github/workflows/mutation.yml' push: diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index 6b4231f..642c826 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -17,7 +17,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/oracle.yml b/.github/workflows/oracle.yml index 51ca673..40b7074 100644 --- a/.github/workflows/oracle.yml +++ b/.github/workflows/oracle.yml @@ -17,7 +17,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/pgsql.yml b/.github/workflows/pgsql.yml index 070f053..a926409 100644 --- a/.github/workflows/pgsql.yml +++ b/.github/workflows/pgsql.yml @@ -17,7 +17,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml index a6f5a57..add2ba7 100644 --- a/.github/workflows/rector-cs.yml +++ b/.github/workflows/rector-cs.yml @@ -18,7 +18,9 @@ concurrency: cancel-in-progress: true jobs: - rector: + rector-cs: + permissions: + contents: write # Required to commit formatting fixes back to the PR uses: yiisoft/actions/.github/workflows/rector-cs.yml@master with: php: '8.1' diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index cdcfda0..839ce5b 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -17,7 +17,7 @@ permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: diff --git a/.gitignore b/.gitignore index f1fb048..021a49d 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,3 @@ composer.phar # PhpUnit /phpunit.phar /phpunit.xml -/.phpunit.cache - -# PHP CS Fixer -/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index c809122..35bb490 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -12,6 +12,7 @@ ]); return (new Config()) + ->setCacheFile(__DIR__ . '/runtime/.php-cs-fixer.cache') ->setParallelConfig(ParallelConfigFactory::detect()) ->setRules([ '@PER-CS3.0' => true, diff --git a/Makefile b/Makefile index dcc0cf6..ec1ea81 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,8 @@ vendor/bin/roave-infection-static-analysis-plugin \ --only-covered" ## Run mutation tests using Infection mutation: run -composer-require-checker: CMD="vendor/bin/composer-require-checker" ## Check dependencies using Composer Require Checker -composer-require-checker: run +composer-dependency-analyser: CMD="vendor/bin/composer-dependency-analyser" ## Check dependencies using Composer Dependency Analyser +composer-dependency-analyser: run rector: CMD="vendor/bin/rector" ## Check code style using Rector rector: run diff --git a/composer.json b/composer.json index 677bc2f..c244cd7 100644 --- a/composer.json +++ b/composer.json @@ -34,13 +34,13 @@ }, "require-dev": { "ext-pdo": "*", - "friendsofphp/php-cs-fixer": "^3.92.0", - "phpunit/phpunit": "^10.5.60", - "rector/rector": "^2.2.14", - "roave/infection-static-analysis-plugin": "^1.35", + "bamarni/composer-bin-plugin": "^1.9.1", + "friendsofphp/php-cs-fixer": "^3.95.27", + "phpunit/phpunit": "^10.5.66", + "rector/rector": "^2.7.0", "shipmonk/composer-dependency-analyser": "^1.8", "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.9.1", + "vimeo/psalm": "^6.20.0", "vlucas/phpdotenv": "^5.6.2", "yiisoft/db-mssql": "^2.0", "yiisoft/db-mysql": "^2.0", @@ -62,11 +62,17 @@ }, "files": ["tests/bootstrap.php"] }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "target-directory": "tools", + "forward-command": true + } + }, "config": { "sort-packages": true, "allow-plugins": { - "infection/extension-installer": true, - "composer/package-versions-deprecated": true + "bamarni/composer-bin-plugin": true } }, "scripts": { diff --git a/docker/Dockerfile b/docker/Dockerfile index 41923b1..9129422 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -87,7 +87,7 @@ COPY --from=composer /composer /usr/bin/composer # Code COPY . /code -RUN rm -f /code/composer.lock +RUN rm -f /code/composer.lock /code/tools/*/composer.lock WORKDIR /code # PHP packages diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 16e2851..e2f9ee6 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ withPaths([ @@ -20,5 +19,4 @@ ->withSkip([ ClosureToArrowFunctionRector::class, ReadOnlyPropertyRector::class, - NullToStrictStringFuncCallArgRector::class, ]); diff --git a/runtime/.gitignore b/runtime/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/runtime/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Base/DataTrait.php b/tests/Base/DataTrait.php index 9f2258c..404a77b 100644 --- a/tests/Base/DataTrait.php +++ b/tests/Base/DataTrait.php @@ -41,9 +41,7 @@ abstract protected function getConnectionId(): string; protected function getConnection(): PdoConnectionInterface { $connectionId = $this->getConnectionId(); - if (!isset(self::$connection[$connectionId])) { - self::$connection[$connectionId] = $this->makeConnection(); - } + self::$connection[$connectionId] ??= $this->makeConnection(); return self::$connection[$connectionId]; } diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000..cf452dc --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1,2 @@ +/*/vendor +/*/composer.lock diff --git a/tools/infection/composer.json b/tools/infection/composer.json new file mode 100644 index 0000000..917bef6 --- /dev/null +++ b/tools/infection/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "roave/infection-static-analysis-plugin": "^1.35" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +} From 2d2aa5c1d718d6d75cdafd4f2270704a73562966 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 20 Oct 2026 12:07:22 +0300 Subject: [PATCH 2/3] Introduce `yiisoft/code-style` --- .php-cs-fixer.dist.php | 11 +++++------ composer.json | 1 + rector.php | 12 +++--------- src/QueryDataReader.php | 2 ++ 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 35bb490..0e03959 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,22 +2,21 @@ declare(strict_types=1); -use PhpCsFixer\Config; use PhpCsFixer\Finder; use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; +use Yiisoft\CodeStyle\ConfigBuilder; $finder = (new Finder())->in([ __DIR__ . '/src', __DIR__ . '/tests', ]); -return (new Config()) +return ConfigBuilder::build() ->setCacheFile(__DIR__ . '/runtime/.php-cs-fixer.cache') + ->setRiskyAllowed(true) ->setParallelConfig(ParallelConfigFactory::detect()) ->setRules([ - '@PER-CS3.0' => true, - 'no_unused_imports' => true, - 'ordered_class_elements' => true, - 'class_attributes_separation' => ['elements' => ['method' => 'one']], + '@Yiisoft/Core' => true, + '@Yiisoft/Core:risky' => true, ]) ->setFinder($finder); diff --git a/composer.json b/composer.json index c244cd7..c841285 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,7 @@ "spatie/phpunit-watcher": "^1.24", "vimeo/psalm": "^6.20.0", "vlucas/phpdotenv": "^5.6.2", + "yiisoft/code-style": "^1.1", "yiisoft/db-mssql": "^2.0", "yiisoft/db-mysql": "^2.0", "yiisoft/db-oracle": "^2.0", diff --git a/rector.php b/rector.php index b5976b4..3a21a43 100644 --- a/rector.php +++ b/rector.php @@ -2,10 +2,8 @@ declare(strict_types=1); -use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; -use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector; -use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; +use Yiisoft\CodeStyle\Rector\SetList; return RectorConfig::configure() ->withPaths([ @@ -13,10 +11,6 @@ __DIR__ . '/tests', ]) ->withPhpSets(php81: true) - ->withRules([ - InlineConstructorDefaultToPropertyRector::class, - ]) - ->withSkip([ - ClosureToArrowFunctionRector::class, - ReadOnlyPropertyRector::class, + ->withSets([ + SetList::YII_CORE, ]); diff --git a/src/QueryDataReader.php b/src/QueryDataReader.php index c29cc00..fd23255 100644 --- a/src/QueryDataReader.php +++ b/src/QueryDataReader.php @@ -39,6 +39,8 @@ use function is_string; use function sprintf; +use const SORT_ASC; + /** * @template TKey as array-key * @template TValue as array|object From 23805ba950b32da687d6a847b965a429d766ffee Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Tue, 20 Oct 2026 12:09:24 +0300 Subject: [PATCH 3/3] Use yiisoft/code-style for PHP CS Fixer and Rector configs - Add rector composer script - Explicitly import SORT_ASC constant in QueryDataReader --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a82405e..571be26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.1 under development -- no changes in this release. +- Enh #146: Explicitly import `SORT_ASC` constant in `QueryDataReader` (@vjik) ## 1.0.0 December 13, 2025