From f3c34b31389f406114b051e3a1957559a4d14966 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 30 Nov 2025 11:50:10 +0300 Subject: [PATCH 01/10] PHP 8.5 support --- .github/workflows/build.yml | 1 + .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/mutation.yml | 2 +- .github/workflows/rector-cs.yml | 2 +- CHANGELOG.md | 2 +- README.md | 2 +- composer.json | 14 ++++++++++---- tools/.gitignore | 2 ++ tools/infection/composer.json | 10 ++++++++++ tools/psalm/composer.json | 5 +++++ 10 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 tools/.gitignore create mode 100644 tools/infection/composer.json create mode 100644 tools/psalm/composer.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0cb149b..0f70d0e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: - 8.2 - 8.3 - 8.4 + - 8.5 mssql: - 2022-latest diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index 1face1f2..2f8aece6 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -25,6 +25,6 @@ jobs: uses: yiisoft/actions/.github/workflows/composer-require-checker.yml@master with: php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] required-packages: >- ['db'] diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index 547990de..f0b62ed9 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -34,7 +34,7 @@ jobs: - ubuntu-latest php: - - 8.4 + - 8.5 services: mssql: diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml index 3c670a95..d6a42ee5 100644 --- a/.github/workflows/rector-cs.yml +++ b/.github/workflows/rector-cs.yml @@ -24,6 +24,6 @@ jobs: token: ${{ secrets.YIISOFT_GITHUB_TOKEN }} with: repository: ${{ github.event.pull_request.head.repo.full_name }} - php: '8.4' + php: '8.5' required-packages: >- ['db'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 92274817..7ab963fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ - New #339: Add `IndexType` and `IndexMethod` classes (@Tigrov) - Bug #343: Explicitly mark nullable parameters (@vjik) - New #342, #405: Support JSON type (@Tigrov) -- Chg #344: Change supported PHP versions to `8.1 - 8.4` (@Tigrov) +- Chg #344, #418: Change supported PHP versions to `8.1 - 8.5` (@Tigrov, @vjik) - Chg #344: Change return type of `Command::insertWithReturningPks()` method to `array|false` (@Tigrov) - New #345: Add parameters `$ifExists` and `$cascade` to `CommandInterface::dropTable()` and `DDLQueryBuilderInterface::dropTable()` methods (@vjik) diff --git a/README.md b/README.md index 43cde689..8d9b45f6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Driver supports Microsoft SQL Server 2017 or higher. ## Requirements -- PHP 8.1 - 8.4. +- PHP 8.1 - 8.5. - `pdo_sqlsrv` PHP extension. ## Installation diff --git a/composer.json b/composer.json index 2f5544ec..10b05426 100644 --- a/composer.json +++ b/composer.json @@ -31,18 +31,17 @@ } ], "require": { - "php": "8.1 - 8.4", + "php": "8.1 - 8.5", "ext-pdo": "*", "yiisoft/db": "dev-master" }, "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.3", "friendsofphp/php-cs-fixer": "^3.89.1", "maglnet/composer-require-checker": "^4.7.1", "phpunit/phpunit": "^10.5.45", "rector/rector": "^2.0.10", - "roave/infection-static-analysis-plugin": "^1.35", "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.8.8", "vlucas/phpdotenv": "^5.6.1", "yiisoft/aliases": "^2.0", "yiisoft/psr-dummy-provider": "^1.0", @@ -64,10 +63,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, + "bamarni/composer-bin-plugin": true, "composer/package-versions-deprecated": true } }, diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 00000000..cf452dcf --- /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 00000000..18be2ea1 --- /dev/null +++ b/tools/infection/composer.json @@ -0,0 +1,10 @@ +{ + "require-dev": { + "infection/infection": "^0.26 || ^0.31.9" + }, + "config": { + "allow-plugins": { + "infection/extension-installer": true + } + } +} diff --git a/tools/psalm/composer.json b/tools/psalm/composer.json new file mode 100644 index 00000000..44e11e3e --- /dev/null +++ b/tools/psalm/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "vimeo/psalm": "^5.26.1 || ^6.8.8" + } +} From ded7b2e65cf85622923b995f49d3c4a441577e62 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 30 Nov 2025 16:17:48 +0300 Subject: [PATCH 02/10] rm test --- tests/Type/BigIntTest.php | 43 --------------------------------------- 1 file changed, 43 deletions(-) diff --git a/tests/Type/BigIntTest.php b/tests/Type/BigIntTest.php index b74779a5..eac3cb33 100644 --- a/tests/Type/BigIntTest.php +++ b/tests/Type/BigIntTest.php @@ -82,49 +82,6 @@ public function testDefaultValueWithInsert(): void $db->createCommand()->dropTable('bigint_default')->execute(); } - /** - * Max value is `9223372036854775807`, but when the value is greater than `9223372036854775807` it is out of range - * and save as `9223372036854775807`. - */ - public function testMaxValue(): void - { - $db = $this->getSharedConnection(); - $this->loadFixture(FixtureDump::TYPE_BIGINT); - - $command = $db->createCommand(); - $command->insert('bigint', ['Mybigint1' => '9223372036854775807', 'Mybigint2' => '0'])->execute(); - - $this->assertSame( - [ - 'id' => '1', - 'Mybigint1' => '9223372036854775807', - 'Mybigint2' => '0', - ], - $command->setSql( - <<queryOne(), - ); - - $command->insert('bigint', ['Mybigint1' => '9223372036854775808', 'Mybigint2' => null])->execute(); - - $this->assertSame( - [ - 'id' => '2', - 'Mybigint1' => '9223372036854775807', - 'Mybigint2' => null, - ], - $command->setSql( - <<queryOne(), - ); - - $db->createCommand()->dropTable('bigint')->execute(); - } - /** * Min value is `-9223372036854775808`, but when the value is less than `-9223372036854775808` it is out of range * and save as `-9223372036854775808`. From 76fe0fc860b620e2c425c5414b133baafc85d211 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 30 Nov 2025 16:28:00 +0300 Subject: [PATCH 03/10] fix --- .github/workflows/mutation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index f0b62ed9..53343e8d 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -67,8 +67,8 @@ jobs: ini-values: memory_limit=-1 coverage: pcov - - name: Update composer. - run: composer self-update + - name: Install Composer dependencies + uses: ramsey/composer-install@v3 - name: Install db. uses: yiisoft/actions/install-packages@master From 9d3fb2e04a15db69f4ed671abdf51da3789b2e63 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 30 Nov 2025 17:02:02 +0300 Subject: [PATCH 04/10] fix --- CHANGELOG.md | 1 + src/Column/ColumnFactory.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ab963fd..7f493dbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ - Bug #408, #409: Add `identity` support in `Schema::loadResultColumn()` (@vjik) - Chg #413: Throw exception on "unsigned" column usage (@vjik) - New #415: Add enumeration column type support (@vjik) +- New #418: Trim dot in column default value normalization to prevent PHP 8.5+ warnings on large values (@vjik) ## 1.2.0 March 21, 2024 diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 698e0eb5..64ed22c2 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -115,6 +115,10 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte return hex2bin(substr($defaultValue, 2)); } + if (is_numeric($defaultValue)) { + $defaultValue = rtrim('.', $defaultValue); + } + return parent::normalizeNotNullDefaultValue($defaultValue, $column); } } From 376038a057046fddea34cd68685e7466fe2cd883 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 30 Nov 2025 17:09:10 +0300 Subject: [PATCH 05/10] fix --- src/Column/ColumnFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 64ed22c2..11531334 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -116,7 +116,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte } if (is_numeric($defaultValue)) { - $defaultValue = rtrim('.', $defaultValue); + $defaultValue = rtrim($defaultValue, '.'); } return parent::normalizeNotNullDefaultValue($defaultValue, $column); From a4af8e6a08a206453b1f070475153451b919b9db Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 1 Dec 2025 09:49:20 +0300 Subject: [PATCH 06/10] improve --- src/Column/ColumnFactory.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 11531334..4ece753f 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -115,9 +115,7 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte return hex2bin(substr($defaultValue, 2)); } - if (is_numeric($defaultValue)) { - $defaultValue = rtrim($defaultValue, '.'); - } + $defaultValue = preg_replace('~^\((\d+)\.\)$~', '(${1})', $defaultValue); return parent::normalizeNotNullDefaultValue($defaultValue, $column); } From 9429b11d88c091a3c09211538394e53c863bded8 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 1 Dec 2025 10:21:35 +0300 Subject: [PATCH 07/10] fix --- tests/ColumnFactoryTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/ColumnFactoryTest.php b/tests/ColumnFactoryTest.php index 2930f3cf..9424fba8 100644 --- a/tests/ColumnFactoryTest.php +++ b/tests/ColumnFactoryTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\Attributes\DataProviderExternal; use Yiisoft\Db\Mssql\Column\ColumnFactory; use Yiisoft\Db\Mssql\Tests\Provider\ColumnFactoryProvider; +use Yiisoft\Db\Mssql\Tests\Support\IntegrationTestTrait; use Yiisoft\Db\Schema\Column\ColumnInterface; use Yiisoft\Db\Tests\Common\CommonColumnFactoryTest; @@ -15,6 +16,8 @@ */ final class ColumnFactoryTest extends CommonColumnFactoryTest { + use IntegrationTestTrait; + #[DataProviderExternal(ColumnFactoryProvider::class, 'dbTypes')] public function testFromDbType(string $dbType, string $expectedType, string $expectedInstanceOf): void { From f71a901fae639e04112c1634e065736f3e3802c4 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 1 Dec 2025 10:27:41 +0300 Subject: [PATCH 08/10] fix --- src/Column/ColumnFactory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index 4ece753f..ff05b88d 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -115,6 +115,9 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte return hex2bin(substr($defaultValue, 2)); } + /** + * @var string $defaultValue We use correct regex, so it always will be a string. + */ $defaultValue = preg_replace('~^\((\d+)\.\)$~', '(${1})', $defaultValue); return parent::normalizeNotNullDefaultValue($defaultValue, $column); From e5f83e2106ef7310bcea8b74ffd90f11795c69c9 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 1 Dec 2025 11:48:42 +0300 Subject: [PATCH 09/10] Update src/Column/ColumnFactory.php Co-authored-by: Sergei Tigrov --- src/Column/ColumnFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index ff05b88d..b92aa55a 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -118,7 +118,9 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte /** * @var string $defaultValue We use correct regex, so it always will be a string. */ - $defaultValue = preg_replace('~^\((\d+)\.\)$~', '(${1})', $defaultValue); + if (preg_match('~^\((\d+)\.\)$~', $defaultValue, $matches) === 1) { + return $column->phpTypecast($matches[1]); + } return parent::normalizeNotNullDefaultValue($defaultValue, $column); } From ea39cbdb7df2b485a1c89449df350c5fadfe5f85 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 1 Dec 2025 11:49:26 +0300 Subject: [PATCH 10/10] fix --- src/Column/ColumnFactory.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Column/ColumnFactory.php b/src/Column/ColumnFactory.php index b92aa55a..0ee03f3c 100644 --- a/src/Column/ColumnFactory.php +++ b/src/Column/ColumnFactory.php @@ -115,9 +115,6 @@ protected function normalizeNotNullDefaultValue(string $defaultValue, ColumnInte return hex2bin(substr($defaultValue, 2)); } - /** - * @var string $defaultValue We use correct regex, so it always will be a string. - */ if (preg_match('~^\((\d+)\.\)$~', $defaultValue, $matches) === 1) { return $column->phpTypecast($matches[1]); }