diff --git a/.github/workflows/rector.yml b/.github/workflows/rector-cs.yml similarity index 97% rename from .github/workflows/rector.yml rename to .github/workflows/rector-cs.yml index d6a42ee5..3982a9c7 100644 --- a/.github/workflows/rector.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.5' + php: '8.1' required-packages: >- ['db'] diff --git a/.gitignore b/.gitignore index 391f2472..48e43110 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ composer.phar # 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 index c8091220..e9cea90b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -12,11 +12,23 @@ ]); 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/CHANGELOG.md b/CHANGELOG.md index 0ababe81..2fb630c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.0.1 under development - Bug #413: Fix "GROUP BY" builder ignoring parameters (@vjik) +- Enh #414: Explicitly import classes and constants in "use" section (@mspirkov) ## 2.0.0 December 05, 2025 diff --git a/src/Builder/InBuilder.php b/src/Builder/InBuilder.php index ace52827..f90a6cd6 100644 --- a/src/Builder/InBuilder.php +++ b/src/Builder/InBuilder.php @@ -10,13 +10,14 @@ use Yiisoft\Db\Exception\InvalidConfigException; use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Expression\ExpressionInterface; +use Yiisoft\Db\QueryBuilder\Condition\In; use function implode; use function is_array; use function str_contains; /** - * Build an object of {@see \Yiisoft\Db\QueryBuilder\Condition\In} into SQL expressions for SQLite Server. + * Build an object of {@see In} into SQL expressions for SQLite Server. */ final class InBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\InBuilder { diff --git a/src/Builder/LikeBuilder.php b/src/Builder/LikeBuilder.php index 6b07a5d9..31ddd881 100644 --- a/src/Builder/LikeBuilder.php +++ b/src/Builder/LikeBuilder.php @@ -6,9 +6,10 @@ use Yiisoft\Db\Exception\NotSupportedException; use Yiisoft\Db\Expression\ExpressionInterface; +use Yiisoft\Db\QueryBuilder\Condition\LikeCondition; /** - * Build an object of {@see \Yiisoft\Db\QueryBuilder\Condition\LikeCondition} into SQL expressions for SQLite Server. + * Build an object of {@see LikeCondition} into SQL expressions for SQLite Server. */ final class LikeBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\LikeBuilder { diff --git a/src/Command.php b/src/Command.php index e5ad9e28..81466b99 100644 --- a/src/Command.php +++ b/src/Command.php @@ -16,6 +16,8 @@ use function preg_match_all; use function strpos; +use const PREG_SET_ORDER; + /** * Implements a database command that can be executed with a PDO (PHP Data Object) database connection for SQLite * Server. diff --git a/src/Driver.php b/src/Driver.php index 17296da0..12414d69 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -7,6 +7,8 @@ use PDO; use Yiisoft\Db\Driver\Pdo\AbstractPdoDriver; +use const PHP_VERSION_ID; + /** * Implements the SQLite Server driver based on the PDO (PHP Data Objects) extension. * diff --git a/src/Schema.php b/src/Schema.php index 60767b79..ef5674f7 100644 --- a/src/Schema.php +++ b/src/Schema.php @@ -25,6 +25,8 @@ use function in_array; use function strncasecmp; +use const PREG_SET_ORDER; + /** * Implements the SQLite Server specific schema, supporting SQLite 3.3.0 or higher. * diff --git a/src/Transaction.php b/src/Transaction.php index 36acd04c..5e82edfd 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -9,6 +9,7 @@ use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\Exception\InvalidConfigException; use Yiisoft\Db\Exception\NotSupportedException; +use Yiisoft\Db\Transaction\TransactionInterface; /** * Implements the SQLite Server specific transaction. @@ -20,8 +21,8 @@ final class Transaction extends AbstractPdoTransaction * * @param string $level The transaction isolation level to use for this transaction. * - * @see \Yiisoft\Db\Transaction\TransactionInterface::READ_UNCOMMITTED - * @see \Yiisoft\Db\Transaction\TransactionInterface::SERIALIZABLE + * @see TransactionInterface::READ_UNCOMMITTED + * @see TransactionInterface::SERIALIZABLE * * @throws Exception * @throws InvalidConfigException diff --git a/tests/Provider/QueryBuilderProvider.php b/tests/Provider/QueryBuilderProvider.php index 32a68987..2e25ad6f 100644 --- a/tests/Provider/QueryBuilderProvider.php +++ b/tests/Provider/QueryBuilderProvider.php @@ -14,6 +14,7 @@ use Yiisoft\Db\QueryBuilder\Condition\In; use Yiisoft\Db\Sqlite\Column\ColumnBuilder; use Yiisoft\Db\Tests\Support\TraversableObject; +use Yiisoft\Db\Connection\ConnectionInterface; use function array_replace; use function array_splice; @@ -168,7 +169,7 @@ public static function insertReturningPks(): array ], 'carry passed params (query)' => [ 'customer', - static fn(\Yiisoft\Db\Connection\ConnectionInterface $db) => (new Query($db)) + static fn(ConnectionInterface $db) => (new Query($db)) ->select(['email', 'name', 'address', 'is_active', 'related_id']) ->from('customer') ->where( @@ -460,7 +461,7 @@ public static function multiOperandFunctionBuilder(): iterable ]; yield 'ArrayMerge with 4 operands' => [ ArrayMerge::class, - static fn(\Yiisoft\Db\Connection\ConnectionInterface $db) => [ + static fn(ConnectionInterface $db) => [ [1, 2, 3], new ArrayValue([5, 6, 7]), $stringParam,