diff --git a/.github/workflows/rector-cs.yml b/.github/workflows/rector-cs.yml index d6a42ee5f..3982a9c75 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.5' + php: '8.1' required-packages: >- ['db'] diff --git a/.gitignore b/.gitignore index 391f24727..48e431101 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 c8091220b..e9cea90b9 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 0ab1cd132..ee1b976a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Enh #477, #478: Improve performance of `ArrayParser::parse()` method (@Tigrov) - Enh #478: Improve performance of `StructuredParser::parse()` method (@Tigrov) +- Enh #479: Explicitly import functions and constants in "use" section (@mspirkov) ## 2.0.0 December 05, 2025 diff --git a/src/Column/BitColumn.php b/src/Column/BitColumn.php index 9722242e8..9f177562c 100644 --- a/src/Column/BitColumn.php +++ b/src/Column/BitColumn.php @@ -9,6 +9,7 @@ use Yiisoft\Db\Schema\Column\AbstractColumn; use function bindec; +use function is_string; final class BitColumn extends AbstractColumn { diff --git a/src/Column/ColumnBuilder.php b/src/Column/ColumnBuilder.php index 85daba878..f489edcb1 100644 --- a/src/Column/ColumnBuilder.php +++ b/src/Column/ColumnBuilder.php @@ -9,6 +9,8 @@ use Yiisoft\Db\Schema\Column\DateTimeColumn; use Yiisoft\Db\Schema\Column\DoubleColumn; +use const PHP_INT_SIZE; + final class ColumnBuilder extends \Yiisoft\Db\Schema\Column\ColumnBuilder { public static function boolean(): BooleanColumn diff --git a/src/Column/RangeBoundColumnFactory.php b/src/Column/RangeBoundColumnFactory.php index 6008dbb8e..a3180ebef 100644 --- a/src/Column/RangeBoundColumnFactory.php +++ b/src/Column/RangeBoundColumnFactory.php @@ -8,6 +8,8 @@ use Yiisoft\Db\Schema\Column\DateTimeColumn; use Yiisoft\Db\Schema\Column\DoubleColumn; +use const PHP_INT_SIZE; + /** * @internal */ diff --git a/tests/CommandTest.php b/tests/CommandTest.php index 31e5e5231..4dc25b838 100644 --- a/tests/CommandTest.php +++ b/tests/CommandTest.php @@ -15,6 +15,7 @@ use Yiisoft\Db\Tests\Common\CommonCommandTest; use function serialize; +use function strlen; /** * @group pgsql diff --git a/tests/Provider/QueryBuilderProvider.php b/tests/Provider/QueryBuilderProvider.php index 8b90aba21..0ef78c864 100644 --- a/tests/Provider/QueryBuilderProvider.php +++ b/tests/Provider/QueryBuilderProvider.php @@ -628,7 +628,7 @@ public static function multiOperandFunctionBuilder(): iterable ]; $data['Longest with 3 operands'][2] = "(SELECT value FROM (SELECT :qp0 AS value UNION SELECT (SELECT 'longest'::text)" . ' AS value UNION SELECT :qp1 AS value) AS t ORDER BY LENGTH(value) DESC LIMIT 1)'; - $data['Shortest with 3 operands'][1] = static fn(Connectioninterface $db) => [ + $data['Shortest with 3 operands'][1] = static fn(ConnectionInterface $db) => [ new Value('short'), $db->select(new Expression("'longest'::text")), new Param('string', DataType::STRING), diff --git a/tests/Provider/SchemaProvider.php b/tests/Provider/SchemaProvider.php index eecc595d0..834deda1b 100644 --- a/tests/Provider/SchemaProvider.php +++ b/tests/Provider/SchemaProvider.php @@ -26,6 +26,8 @@ use Yiisoft\Db\Schema\Column\StringColumn; use Yiisoft\Db\Tests\Support\Assert; +use function sprintf; + final class SchemaProvider extends \Yiisoft\Db\Tests\Provider\SchemaProvider { public static function columns(): array diff --git a/tests/SchemaTest.php b/tests/SchemaTest.php index 3a9b4bd82..fa585573e 100644 --- a/tests/SchemaTest.php +++ b/tests/SchemaTest.php @@ -23,6 +23,8 @@ use Yiisoft\Db\Tests\Common\CommonSchemaTest; use Yiisoft\Db\Tests\Support\TestHelper; +use function count; + /** * @group pgsql */