diff --git a/.gitignore b/.gitignore index f1fb048..d3b3a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,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 c809122..e9cea90 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 8d03629..6295dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.0.1 under development -- no changes in this release. +Enh #246: Explicitly import functions and constants in "use" section (@mspirkov) ## 2.0.0 December 13, 2025 diff --git a/src/Paginator/KeysetPaginator.php b/src/Paginator/KeysetPaginator.php index 25481bc..b68e13e 100644 --- a/src/Paginator/KeysetPaginator.php +++ b/src/Paginator/KeysetPaginator.php @@ -25,6 +25,9 @@ use function reset; use function sprintf; +use const SORT_ASC; +use const SORT_DESC; + /** * Keyset paginator. * diff --git a/src/Reader/Iterable/IterableDataReader.php b/src/Reader/Iterable/IterableDataReader.php index 1c1675f..064a9aa 100644 --- a/src/Reader/Iterable/IterableDataReader.php +++ b/src/Reader/Iterable/IterableDataReader.php @@ -33,6 +33,8 @@ use function iterator_to_array; use function uasort; +use const SORT_DESC; + /** * Iterable data reader takes iterable data as a source and can: * diff --git a/src/Reader/OrderHelper.php b/src/Reader/OrderHelper.php index bcf01ea..d329c69 100644 --- a/src/Reader/OrderHelper.php +++ b/src/Reader/OrderHelper.php @@ -9,6 +9,8 @@ use function substr; use function trim; +use const PREG_SPLIT_NO_EMPTY; + /** * @psalm-import-type TOrder from Sort */ diff --git a/src/Reader/Sort.php b/src/Reader/Sort.php index 795b9d2..33a4e55 100644 --- a/src/Reader/Sort.php +++ b/src/Reader/Sort.php @@ -12,6 +12,9 @@ use function is_int; use function is_string; +use const SORT_ASC; +use const SORT_DESC; + /** * Sort represents data sorting settings: * diff --git a/tests/Paginator/KeysetPaginatorTest.php b/tests/Paginator/KeysetPaginatorTest.php index 34873b5..07edfe9 100644 --- a/tests/Paginator/KeysetPaginatorTest.php +++ b/tests/Paginator/KeysetPaginatorTest.php @@ -34,6 +34,8 @@ use function reset; use function sprintf; +use const SORT_ASC; + final class KeysetPaginatorTest extends TestCase { use PageTokenAssertTrait; diff --git a/tests/Paginator/OffsetPaginatorTest.php b/tests/Paginator/OffsetPaginatorTest.php index 3999f18..52a850f 100644 --- a/tests/Paginator/OffsetPaginatorTest.php +++ b/tests/Paginator/OffsetPaginatorTest.php @@ -23,6 +23,8 @@ use Yiisoft\Data\Tests\Support\StubOffsetData; use Yiisoft\Data\Tests\TestCase; +use function sprintf; + final class OffsetPaginatorTest extends TestCase { use PageTokenAssertTrait; diff --git a/tests/Reader/SortTest.php b/tests/Reader/SortTest.php index e52f949..9d34b32 100644 --- a/tests/Reader/SortTest.php +++ b/tests/Reader/SortTest.php @@ -9,6 +9,9 @@ use Yiisoft\Data\Reader\Sort; use Yiisoft\Data\Tests\TestCase; +use const SORT_ASC; +use const SORT_DESC; + final class SortTest extends TestCase { public function testInvalidConfigWithoutFieldName(): void diff --git a/tests/Support/MutationDataReader.php b/tests/Support/MutationDataReader.php index 85567e2..186fbdd 100644 --- a/tests/Support/MutationDataReader.php +++ b/tests/Support/MutationDataReader.php @@ -13,6 +13,8 @@ use Yiisoft\Data\Reader\Sort; use Yiisoft\Data\Reader\SortableDataInterface; +use function call_user_func; + final class MutationDataReader implements ReadableDataInterface, FilterableDataInterface,