From 9473ff138d07d5010eb0e45a5e43f7e20ffabf51 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: Sat, 10 Jan 2026 22:15:55 +0400 Subject: [PATCH 1/3] Update the PHP CS Fixer configuration --- .gitignore | 1 + .php-cs-fixer.dist.php | 13 +++++++++++++ src/CompositeRule.php | 1 + src/Manager.php | 2 ++ src/RuleContext.php | 2 ++ src/SimpleAssignmentsStorage.php | 1 + src/SimpleItemsStorage.php | 3 +++ tests/Common/AssignmentsStorageTestTrait.php | 2 ++ tests/Common/ItemsStorageTestTrait.php | 2 ++ tests/Common/ManagerLogicTestTrait.php | 2 ++ tests/ConfigTest.php | 2 ++ 11 files changed, 31 insertions(+) diff --git a/.gitignore b/.gitignore index 1696400a..aa3fd5d4 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ phpunit.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..f66e1d58 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,15 +8,28 @@ $finder = (new Finder())->in([ __DIR__ . '/src', + __DIR__ . '/config', __DIR__ . '/tests', ]); 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/src/CompositeRule.php b/src/CompositeRule.php index baae1ca5..ec3bd423 100644 --- a/src/CompositeRule.php +++ b/src/CompositeRule.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use function in_array; +use function sprintf; /** * Composite rule allows combining multiple rules. diff --git a/src/Manager.php b/src/Manager.php index 1637f1af..4244225b 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -14,6 +14,8 @@ use Yiisoft\Rbac\Exception\ItemAlreadyExistsException; use function is_array; +use function array_key_exists; +use function is_string; /** * Helps to manage RBAC hierarchy and check for permissions. diff --git a/src/RuleContext.php b/src/RuleContext.php index 5e119abf..a8d4eb60 100644 --- a/src/RuleContext.php +++ b/src/RuleContext.php @@ -4,6 +4,8 @@ namespace Yiisoft\Rbac; +use function array_key_exists; + final class RuleContext { public function __construct( diff --git a/src/SimpleAssignmentsStorage.php b/src/SimpleAssignmentsStorage.php index 4f467da2..ad82b4d5 100644 --- a/src/SimpleAssignmentsStorage.php +++ b/src/SimpleAssignmentsStorage.php @@ -5,6 +5,7 @@ namespace Yiisoft\Rbac; use function array_key_exists; +use function in_array; /** * @psalm-type RawAssignment = array{ diff --git a/src/SimpleItemsStorage.php b/src/SimpleItemsStorage.php index 3d8563dc..01226dc4 100644 --- a/src/SimpleItemsStorage.php +++ b/src/SimpleItemsStorage.php @@ -4,6 +4,9 @@ namespace Yiisoft\Rbac; +use function array_key_exists; +use function in_array; + /** * @psalm-type RawItem = array{ * type: Item::TYPE_*, diff --git a/tests/Common/AssignmentsStorageTestTrait.php b/tests/Common/AssignmentsStorageTestTrait.php index 82051d95..a5e054fe 100644 --- a/tests/Common/AssignmentsStorageTestTrait.php +++ b/tests/Common/AssignmentsStorageTestTrait.php @@ -13,6 +13,8 @@ use Yiisoft\Rbac\Tests\Support\FakeAssignmentsStorage; use Yiisoft\Rbac\Tests\Support\FakeItemsStorage; +use function count; + trait AssignmentsStorageTestTrait { private ?ItemsStorageInterface $itemsStorage = null; diff --git a/tests/Common/ItemsStorageTestTrait.php b/tests/Common/ItemsStorageTestTrait.php index ec5de813..3722573d 100644 --- a/tests/Common/ItemsStorageTestTrait.php +++ b/tests/Common/ItemsStorageTestTrait.php @@ -13,6 +13,8 @@ use Yiisoft\Rbac\Tests\Support\FakeItemsStorage; use Yiisoft\Rbac\Tests\Support\TrueRule; +use function count; + trait ItemsStorageTestTrait { private int $initialRolesCount = 0; diff --git a/tests/Common/ManagerLogicTestTrait.php b/tests/Common/ManagerLogicTestTrait.php index c7939841..fe68abd6 100644 --- a/tests/Common/ManagerLogicTestTrait.php +++ b/tests/Common/ManagerLogicTestTrait.php @@ -27,6 +27,8 @@ use Yiisoft\Rbac\Tests\Support\TrueRule; use Yiisoft\Rbac\Tests\Support\WannabeRule; +use function count; + trait ManagerLogicTestTrait { public static function dataUserHasPermissionGeneric(): array diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 0d7b3e8e..a0cd30e2 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -15,6 +15,8 @@ use Yiisoft\Rbac\Tests\Support\FakeAssignmentsStorage; use Yiisoft\Rbac\Tests\Support\FakeItemsStorage; +use function dirname; + final class ConfigTest extends TestCase { public function testBase(): void From 5dc9d334b6a8df475ab8867eea868d3195dcfc5e 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: Sat, 10 Jan 2026 22:16:44 +0400 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92d5e52c..31c9b123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 2.1.3 under development -- no changes in this release. +- Enh #285: Explicitly import functions in "use" section (@mspirkov) ## 2.1.2 December 19, 2025 From bfda6d9d5ad247436ef1fc034c71a0549751d041 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: Sat, 10 Jan 2026 22:19:01 +0400 Subject: [PATCH 3/3] self review --- .php-cs-fixer.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index f66e1d58..7571f304 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -7,8 +7,8 @@ use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; $finder = (new Finder())->in([ - __DIR__ . '/src', __DIR__ . '/config', + __DIR__ . '/src', __DIR__ . '/tests', ]);