From 599d2a854e167ddbb29e5651a95a4ec4a09ffbb7 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, 8 Jan 2026 20:51:10 +0400 Subject: [PATCH 1/4] Update the PHP CS Fixer configuration --- .php-cs-fixer.dist.php | 2 ++ src/Debug/CommandInterfaceProxy.php | 3 +++ src/Debug/DatabaseCollector.php | 2 ++ src/Debug/TransactionInterfaceDecorator.php | 2 ++ src/Helper/DbUuidHelper.php | 1 + src/QueryBuilder/Condition/Simple.php | 1 + src/Schema/Column/BitColumn.php | 2 ++ tests/Common/CommonColumnFactoryTest.php | 2 ++ tests/Common/CommonCommandTest.php | 2 ++ tests/Common/CommonQueryBuilderTest.php | 1 + tests/Provider/SchemaProvider.php | 2 ++ tests/Support/AnyCaseValue.php | 1 + tests/Support/Assert.php | 1 + tests/Support/TraversableObject.php | 2 ++ 14 files changed, 24 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 841e41e5b..ac4f2aa5a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -13,12 +13,14 @@ ]); 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']], + 'native_function_invocation' => true, 'fully_qualified_strict_types' => [ 'import_symbols' => true ], diff --git a/src/Debug/CommandInterfaceProxy.php b/src/Debug/CommandInterfaceProxy.php index 1e18f1078..9619cc645 100644 --- a/src/Debug/CommandInterfaceProxy.php +++ b/src/Debug/CommandInterfaceProxy.php @@ -12,6 +12,9 @@ use Yiisoft\Db\Query\QueryInterface; use Yiisoft\Db\Schema\Column\ColumnInterface; +use function count; +use function func_get_args; + final class CommandInterfaceProxy implements CommandInterface { public function __construct( diff --git a/src/Debug/DatabaseCollector.php b/src/Debug/DatabaseCollector.php index 76bb89e2a..6fb91f91b 100644 --- a/src/Debug/DatabaseCollector.php +++ b/src/Debug/DatabaseCollector.php @@ -8,6 +8,8 @@ use Yiisoft\Yii\Debug\Collector\CollectorTrait; use Yiisoft\Yii\Debug\Collector\SummaryCollectorInterface; +use function count; + final class DatabaseCollector implements SummaryCollectorInterface { use CollectorTrait; diff --git a/src/Debug/TransactionInterfaceDecorator.php b/src/Debug/TransactionInterfaceDecorator.php index d2b6a667f..0906da414 100644 --- a/src/Debug/TransactionInterfaceDecorator.php +++ b/src/Debug/TransactionInterfaceDecorator.php @@ -6,6 +6,8 @@ use Yiisoft\Db\Transaction\TransactionInterface; +use function func_get_args; + final class TransactionInterfaceDecorator implements TransactionInterface { public function __construct( diff --git a/src/Helper/DbUuidHelper.php b/src/Helper/DbUuidHelper.php index 5958997a0..c157e9877 100644 --- a/src/Helper/DbUuidHelper.php +++ b/src/Helper/DbUuidHelper.php @@ -10,6 +10,7 @@ use function hex2bin; use function preg_match; use function str_replace; +use function strlen; final class DbUuidHelper { diff --git a/src/QueryBuilder/Condition/Simple.php b/src/QueryBuilder/Condition/Simple.php index 0828828a3..78db26ced 100644 --- a/src/QueryBuilder/Condition/Simple.php +++ b/src/QueryBuilder/Condition/Simple.php @@ -8,6 +8,7 @@ use Yiisoft\Db\Expression\ExpressionInterface; use function array_key_exists; +use function is_string; /** * Represents a simple condition like `"column" operator value`. diff --git a/src/Schema/Column/BitColumn.php b/src/Schema/Column/BitColumn.php index 9e8a304fd..0d28b3c8b 100644 --- a/src/Schema/Column/BitColumn.php +++ b/src/Schema/Column/BitColumn.php @@ -7,6 +7,8 @@ use Yiisoft\Db\Constant\ColumnType; use Yiisoft\Db\Expression\ExpressionInterface; +use function is_int; + /** * Represents the metadata for a bit column. */ diff --git a/tests/Common/CommonColumnFactoryTest.php b/tests/Common/CommonColumnFactoryTest.php index 9ad1bdcd9..5ce5330cf 100644 --- a/tests/Common/CommonColumnFactoryTest.php +++ b/tests/Common/CommonColumnFactoryTest.php @@ -16,6 +16,8 @@ use Yiisoft\Db\Tests\Provider\ColumnFactoryProvider; use Yiisoft\Db\Tests\Support\IntegrationTestCase; +use function is_scalar; + abstract class CommonColumnFactoryTest extends IntegrationTestCase { public function testConstructColumnClassMap(): void diff --git a/tests/Common/CommonCommandTest.php b/tests/Common/CommonCommandTest.php index dae3156df..1601dcde1 100644 --- a/tests/Common/CommonCommandTest.php +++ b/tests/Common/CommonCommandTest.php @@ -39,6 +39,8 @@ use function is_string; use function setlocale; use function str_starts_with; +use function count; +use function is_resource; abstract class CommonCommandTest extends IntegrationTestCase { diff --git a/tests/Common/CommonQueryBuilderTest.php b/tests/Common/CommonQueryBuilderTest.php index 90e1b79bd..0e8f16f69 100644 --- a/tests/Common/CommonQueryBuilderTest.php +++ b/tests/Common/CommonQueryBuilderTest.php @@ -43,6 +43,7 @@ use function PHPUnit\Framework\assertEmpty; use function PHPUnit\Framework\assertSame; use function sort; +use function in_array; use const SORT_NATURAL; diff --git a/tests/Provider/SchemaProvider.php b/tests/Provider/SchemaProvider.php index 68dffacd0..b3c8b1853 100644 --- a/tests/Provider/SchemaProvider.php +++ b/tests/Provider/SchemaProvider.php @@ -12,6 +12,8 @@ use Yiisoft\Db\Constraint\Index; use Yiisoft\Db\Schema\SchemaInterface; +use function sprintf; + class SchemaProvider { public static function columns(): array diff --git a/tests/Support/AnyCaseValue.php b/tests/Support/AnyCaseValue.php index 585580849..851f1942b 100644 --- a/tests/Support/AnyCaseValue.php +++ b/tests/Support/AnyCaseValue.php @@ -5,6 +5,7 @@ namespace Yiisoft\Db\Tests\Support; use function strtolower; +use function is_array; final class AnyCaseValue extends CompareValue { diff --git a/tests/Support/Assert.php b/tests/Support/Assert.php index 909d1da46..cd929c522 100644 --- a/tests/Support/Assert.php +++ b/tests/Support/Assert.php @@ -22,6 +22,7 @@ use function ksort; use function ltrim; use function strtolower; +use function count; /** * @psalm-suppress PropertyNotSetInConstructor diff --git a/tests/Support/TraversableObject.php b/tests/Support/TraversableObject.php index a20455f05..40290efb1 100644 --- a/tests/Support/TraversableObject.php +++ b/tests/Support/TraversableObject.php @@ -8,6 +8,8 @@ use Exception; use Iterator; +use function array_key_exists; + /** * TraversableObject * From 6645214742c68c3bbcd62134c0b0264abeae7b5f 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, 8 Jan 2026 20:52:10 +0400 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e623c632..7909ed99e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Bug #1127: Fix `AbstractSchema::hasTable()` and `AbstractSchema::hasView()` methods to support names quoted with curly brackets `{{%table}}` (@batyrmastyr) -- Enh #1145: Explicitly import classes, functions, and constants in "use" section (@mspirkov) +- Enh #1145, #1148: Explicitly import classes, functions, and constants in "use" section (@mspirkov) ## 2.0.0 December 05, 2025 From 9d94417b1beb9fa48ea6509d9313f2984d5046d3 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, 8 Jan 2026 20:56:53 +0400 Subject: [PATCH 3/4] Add `native_constant_invocation` --- .php-cs-fixer.dist.php | 1 + src/Exception/ConvertException.php | 2 ++ src/Exception/Exception.php | 2 ++ src/Helper/DbArrayHelper.php | 4 ++++ src/Query/Query.php | 5 +++++ src/QueryBuilder/AbstractDDLQueryBuilder.php | 2 ++ src/QueryBuilder/AbstractDQLQueryBuilder.php | 3 +++ src/Schema/Column/ColumnBuilder.php | 2 ++ tests/Common/CommonCommandTest.php | 2 ++ tests/Common/CommonQueryBuilderTest.php | 2 ++ tests/Common/CommonQueryTest.php | 3 +++ tests/Db/Driver/Pdo/PdoDriverTest.php | 2 ++ tests/Db/Exception/ConvertExceptionTest.php | 2 ++ tests/Db/Helper/DbArrayHelperTest.php | 2 ++ tests/Db/Query/QueryTest.php | 2 ++ tests/Db/QueryBuilder/QueryBuilderTest.php | 2 ++ tests/Provider/QueryBuilderProvider.php | 2 ++ tests/Support/Assert.php | 2 ++ 18 files changed, 42 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ac4f2aa5a..7dbd1aeba 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -21,6 +21,7 @@ 'ordered_class_elements' => true, 'class_attributes_separation' => ['elements' => ['method' => 'one']], 'native_function_invocation' => true, + 'native_constant_invocation' => true, 'fully_qualified_strict_types' => [ 'import_symbols' => true ], diff --git a/src/Exception/ConvertException.php b/src/Exception/ConvertException.php index 3b46a7953..e64271c25 100644 --- a/src/Exception/ConvertException.php +++ b/src/Exception/ConvertException.php @@ -6,6 +6,8 @@ use PDOException; +use const PHP_EOL; + /** * Converts an exception into a more specific one. * diff --git a/src/Exception/Exception.php b/src/Exception/Exception.php index 0b9231da0..be0318a89 100644 --- a/src/Exception/Exception.php +++ b/src/Exception/Exception.php @@ -6,6 +6,8 @@ use Stringable; +use const PHP_EOL; + /** * Represents an exception that's caused by some DB-related operations. * diff --git a/src/Helper/DbArrayHelper.php b/src/Helper/DbArrayHelper.php index c6fef23eb..438090aba 100644 --- a/src/Helper/DbArrayHelper.php +++ b/src/Helper/DbArrayHelper.php @@ -23,6 +23,10 @@ use function iterator_to_array; use function range; +use const PREG_SPLIT_NO_EMPTY; +use const SORT_ASC; +use const SORT_NUMERIC; + /** * Array manipulation methods. * diff --git a/src/Query/Query.php b/src/Query/Query.php index 7b183f9b8..f499893f5 100644 --- a/src/Query/Query.php +++ b/src/Query/Query.php @@ -44,6 +44,11 @@ use function substr; use function trim; +use const PHP_INT_MAX; +use const PREG_SPLIT_NO_EMPTY; +use const SORT_ASC; +use const SORT_DESC; + /** * Represents a `SELECT` SQL statement in a way that's independent of DBMS. * diff --git a/src/QueryBuilder/AbstractDDLQueryBuilder.php b/src/QueryBuilder/AbstractDDLQueryBuilder.php index e0f598a28..b6d2e3c88 100644 --- a/src/QueryBuilder/AbstractDDLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDDLQueryBuilder.php @@ -16,6 +16,8 @@ use function is_string; use function preg_split; +use const PREG_SPLIT_NO_EMPTY; + /** * It's used to create and change the structure of database objects in a database. * diff --git a/src/QueryBuilder/AbstractDQLQueryBuilder.php b/src/QueryBuilder/AbstractDQLQueryBuilder.php index 6892e6543..3eae9b427 100644 --- a/src/QueryBuilder/AbstractDQLQueryBuilder.php +++ b/src/QueryBuilder/AbstractDQLQueryBuilder.php @@ -59,6 +59,9 @@ use function strtoupper; use function trim; +use const PREG_SPLIT_NO_EMPTY; +use const SORT_DESC; + /** * It's used to query data from a database. * diff --git a/src/Schema/Column/ColumnBuilder.php b/src/Schema/Column/ColumnBuilder.php index b0ec0622a..f661a78c1 100644 --- a/src/Schema/Column/ColumnBuilder.php +++ b/src/Schema/Column/ColumnBuilder.php @@ -6,6 +6,8 @@ use Yiisoft\Db\Constant\ColumnType; +use const PHP_INT_SIZE; + /** * Column builder for database {@see ColumnInterface} instances. * diff --git a/tests/Common/CommonCommandTest.php b/tests/Common/CommonCommandTest.php index 1601dcde1..456bf64f4 100644 --- a/tests/Common/CommonCommandTest.php +++ b/tests/Common/CommonCommandTest.php @@ -42,6 +42,8 @@ use function count; use function is_resource; +use const LC_NUMERIC; + abstract class CommonCommandTest extends IntegrationTestCase { public function testAutoQuoting(): void diff --git a/tests/Common/CommonQueryBuilderTest.php b/tests/Common/CommonQueryBuilderTest.php index 0e8f16f69..7de27c91d 100644 --- a/tests/Common/CommonQueryBuilderTest.php +++ b/tests/Common/CommonQueryBuilderTest.php @@ -46,6 +46,8 @@ use function in_array; use const SORT_NATURAL; +use const SORT_ASC; +use const SORT_DESC; abstract class CommonQueryBuilderTest extends IntegrationTestCase { diff --git a/tests/Common/CommonQueryTest.php b/tests/Common/CommonQueryTest.php index 4d6a76157..f878802bc 100644 --- a/tests/Common/CommonQueryTest.php +++ b/tests/Common/CommonQueryTest.php @@ -18,6 +18,9 @@ use function array_keys; +use const SORT_ASC; +use const SORT_DESC; + abstract class CommonQueryTest extends IntegrationTestCase { public function testAddGroupByExpression(): void diff --git a/tests/Db/Driver/Pdo/PdoDriverTest.php b/tests/Db/Driver/Pdo/PdoDriverTest.php index f8898b563..36f793c2f 100644 --- a/tests/Db/Driver/Pdo/PdoDriverTest.php +++ b/tests/Db/Driver/Pdo/PdoDriverTest.php @@ -11,6 +11,8 @@ use SensitiveParameterValue; use TypeError; +use const PHP_VERSION_ID; + /** * @group db * diff --git a/tests/Db/Exception/ConvertExceptionTest.php b/tests/Db/Exception/ConvertExceptionTest.php index a7424389d..bb742331a 100644 --- a/tests/Db/Exception/ConvertExceptionTest.php +++ b/tests/Db/Exception/ConvertExceptionTest.php @@ -8,6 +8,8 @@ use PHPUnit\Framework\TestCase; use Yiisoft\Db\Exception\ConvertException; +use const PHP_EOL; + /** * @group db * diff --git a/tests/Db/Helper/DbArrayHelperTest.php b/tests/Db/Helper/DbArrayHelperTest.php index f3d87cc08..1164f8e12 100644 --- a/tests/Db/Helper/DbArrayHelperTest.php +++ b/tests/Db/Helper/DbArrayHelperTest.php @@ -11,6 +11,8 @@ use Yiisoft\Db\Tests\Provider\DbArrayHelperProvider; use Exception; +use const E_WARNING; + /** * @group db */ diff --git a/tests/Db/Query/QueryTest.php b/tests/Db/Query/QueryTest.php index e6da7fdf8..c5ef88e83 100644 --- a/tests/Db/Query/QueryTest.php +++ b/tests/Db/Query/QueryTest.php @@ -14,6 +14,8 @@ use function PHPUnit\Framework\assertSame; +use const SORT_DESC; + /** * @group db */ diff --git a/tests/Db/QueryBuilder/QueryBuilderTest.php b/tests/Db/QueryBuilder/QueryBuilderTest.php index 546b6de76..e13b97d20 100644 --- a/tests/Db/QueryBuilder/QueryBuilderTest.php +++ b/tests/Db/QueryBuilder/QueryBuilderTest.php @@ -26,6 +26,8 @@ use function fopen; use function stream_context_create; +use const SORT_DESC; + /** * @group db */ diff --git a/tests/Provider/QueryBuilderProvider.php b/tests/Provider/QueryBuilderProvider.php index 3c98ebb37..3e0912fb5 100644 --- a/tests/Provider/QueryBuilderProvider.php +++ b/tests/Provider/QueryBuilderProvider.php @@ -52,6 +52,8 @@ use function fopen; +use const PREG_SET_ORDER; + class QueryBuilderProvider { protected static string $likeEscapeCharSql = ''; diff --git a/tests/Support/Assert.php b/tests/Support/Assert.php index cd929c522..4aa5d3301 100644 --- a/tests/Support/Assert.php +++ b/tests/Support/Assert.php @@ -24,6 +24,8 @@ use function strtolower; use function count; +use const SORT_STRING; + /** * @psalm-suppress PropertyNotSetInConstructor */ From cc9a70e412ddacdb91c1d18056986133b4d97435 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, 8 Jan 2026 23:00:49 +0400 Subject: [PATCH 4/4] Add declare_strict_types --- .php-cs-fixer.dist.php | 1 + CHANGELOG.md | 1 + src/Constant/ColumnInfoSource.php | 2 ++ 3 files changed, 4 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7dbd1aeba..7571f3048 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -20,6 +20,7 @@ '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' => [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 7909ed99e..d1941284e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Bug #1127: Fix `AbstractSchema::hasTable()` and `AbstractSchema::hasView()` methods to support names quoted with curly brackets `{{%table}}` (@batyrmastyr) - Enh #1145, #1148: Explicitly import classes, functions, and constants in "use" section (@mspirkov) +- Enh #1148: Add `declare(strict_types=1)` to `Yiisoft\Db\Constant\ColumnInfoSource` (@mspirkov) ## 2.0.0 December 05, 2025 diff --git a/src/Constant/ColumnInfoSource.php b/src/Constant/ColumnInfoSource.php index 79cb4f448..b88fecb03 100644 --- a/src/Constant/ColumnInfoSource.php +++ b/src/Constant/ColumnInfoSource.php @@ -1,5 +1,7 @@