From ffdd1ac95020d64dca2415fb491c03d6e57b2fb8 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 7 Feb 2025 12:58:55 +0400 Subject: [PATCH 1/4] Fix `cycle:migrate --split` command --- src/Console/Command/CycleOrm/MigrateCommand.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Console/Command/CycleOrm/MigrateCommand.php b/src/Console/Command/CycleOrm/MigrateCommand.php index 96445cf..5f5f7c6 100644 --- a/src/Console/Command/CycleOrm/MigrateCommand.php +++ b/src/Console/Command/CycleOrm/MigrateCommand.php @@ -66,11 +66,14 @@ public function perform( if ($print->hasChanges()) { if ($this->option('split')) { - \assert($this->container instanceof BinderInterface); - $this->container->bind(GeneratorStrategyInterface::class, MultipleFilesStrategy::class); + $binder = $this->container?->get(BinderInterface::class); + \assert($binder instanceof BinderInterface); + $binder->getBinder('root') + ->bind(GeneratorStrategyInterface::class, MultipleFilesStrategy::class); } $migrations = $this->container->get(GenerateMigrations::class); + \assert($migrations instanceof GenerateMigrations); (new \Cycle\Schema\Compiler())->compile($registry, [$migrations]); From ac510bfc38a49f28e1e11fbece967bbe1721d986 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 7 Feb 2025 13:00:12 +0400 Subject: [PATCH 2/4] Update dependencies --- composer.json | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index 3799397..01d8b0c 100644 --- a/composer.json +++ b/composer.json @@ -30,41 +30,41 @@ ], "require": { "php": ">=8.1", - "cycle/annotated": "^4.0", - "cycle/migrations": "^4.0.1", - "cycle/orm": "^2.0.2", - "cycle/schema-migrations-generator": "^2.1", + "cycle/annotated": "^4.2.3", + "cycle/migrations": "^4.2.4", + "cycle/orm": "^2.9.3", + "cycle/schema-migrations-generator": "^2.3", "cycle/schema-renderer": "^1.2", - "cycle/schema-builder": "^2.7", - "doctrine/inflector": "^1.4 || ^2.0", - "spiral/attributes": "^2.10 || ^3.0", - "spiral/reactor": "^3.0", - "spiral/scaffolder": "^3.0", - "spiral/prototype": "^3.0", - "spiral/console": "^3.0", - "spiral/core": "^3.0", - "spiral/boot": "^3.0", - "spiral/auth": "^3.0", - "spiral/tokenizer": "^3.0", - "spiral/config": "^3.0", - "spiral/filters": "^3.10", - "spiral/data-grid-bridge": "^3.0", - "psr/container": "^1.1 || ^2.0" + "cycle/schema-builder": "^2.11.1", + "doctrine/inflector": "^1.4 || ^2.0.10", + "spiral/attributes": "^2.10 || ^3.1.8", + "spiral/reactor": "^3.15", + "spiral/scaffolder": "^3.15", + "spiral/prototype": "^3.15", + "spiral/console": "^3.15", + "spiral/core": "^3.15", + "spiral/boot": "^3.15", + "spiral/auth": "^3.15", + "spiral/tokenizer": "^3.15", + "spiral/config": "^3.15", + "spiral/filters": "^3.15", + "spiral/data-grid-bridge": "^3.0.1", + "psr/container": "^1.1 || ^2.0.2" }, "require-dev": { - "cycle/entity-behavior": "^1.2", - "doctrine/collections": "^2.0", - "illuminate/collections": "^9.0", - "infection/infection": "^0.26.6", - "mockery/mockery": "^1.5", - "phpunit/phpunit": "^9.5.20", - "spiral-packages/database-seeder": "^3.1", - "spiral/code-style": "^2.2.1", - "spiral/framework": "^3.11.1", + "cycle/entity-behavior": "^1.3.1", + "doctrine/collections": "^2.2.2", + "illuminate/collections": "^10.48", + "infection/infection": "^0.29.9", + "mockery/mockery": "^1.6.12", + "phpunit/phpunit": "^9.6.22", + "spiral-packages/database-seeder": "^3.3", + "spiral/code-style": "^2.2.2", + "spiral/framework": "^3.15.1", "spiral/nyholm-bridge": "^1.3", - "spiral/testing": "^2.4", - "spiral/validator": "^1.5", - "vimeo/psalm": "^5.19" + "spiral/testing": "^2.9", + "spiral/validator": "^1.5.4", + "vimeo/psalm": "^6.4" }, "autoload": { "psr-4": { From 2439048a3ec1d04d425d59856168f9794dcc6a6b Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 7 Feb 2025 13:03:26 +0400 Subject: [PATCH 3/4] Update psalm baseline --- psalm-baseline.xml | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5c95ef7..c13f338 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -13,12 +13,12 @@ normalizedPayload]]> normalizedPayload]]> - - - normalizedPayload]]> + + payload)]]> + @@ -53,10 +53,6 @@ - - - - get($nameGenerator)]]> get($strategy)]]> @@ -110,9 +106,6 @@ - - - config['schema']['generators'] ?? null]]> config['schema']['generators'] ?? null]]> @@ -157,12 +150,6 @@ - - - - - - output]]> @@ -251,10 +238,6 @@ - - - - ask( $this->input, @@ -318,9 +301,6 @@ - - - config->declarationOptions($element)[(string) $this->argument('format')]]]> @@ -392,9 +372,6 @@ - - - expression->getValue()]]> @@ -438,9 +415,6 @@ - - - @@ -466,11 +440,9 @@ + orm]]> - - - orm]]> orm]]> @@ -515,6 +487,10 @@ + + orm->getRepository($role)->findByPK($parameter)]]> + orm->getRepository($role)->findByPK($parameter)]]> + ]]> @@ -533,9 +509,6 @@ config]]> - - - From a3bd66f3fc83587645e45a4e3eccf09a8b7f8dc8 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 7 Feb 2025 13:05:24 +0400 Subject: [PATCH 4/4] Update code style (apply risky rules) --- .php-cs-fixer.dist.php | 2 +- psalm-baseline.xml | 7 +------ psalm.xml | 5 ----- src/Auth/Token.php | 16 ++++++++-------- src/Auth/TokenStorage.php | 2 +- src/Bootloader/DisconnectsBootloader.php | 2 +- src/Bootloader/ValidationBootloader.php | 2 +- src/Console/Command/CycleOrm/RenderCommand.php | 2 +- src/Console/Command/Database/ListCommand.php | 10 +++++----- src/Console/Command/Migrate/AbstractCommand.php | 2 +- src/DataGrid/Writer/PostgresQueryWriter.php | 4 ++-- src/Injector/DatabaseInjector.php | 2 +- tests/src/Auth/TokenStorageTest.php | 8 ++++---- tests/src/Auth/TokenTest.php | 4 ++-- tests/src/BaseTest.php | 6 +++--- .../CycleOrmWarmedUpBootloaderTest.php | 2 +- .../Command/CycleOrm/MigrateCommandTest.php | 2 +- .../Command/CycleOrm/RenderCommandTest.php | 4 ++-- tests/src/DataGrid/GeneratorTest.php | 10 +++++----- .../src/DataGrid/QueryWriter/WriteSorterTest.php | 4 ++-- tests/src/Validation/EntityCheckerTest.php | 4 ++-- tests/src/Validation/EntityCheckerTrait.php | 4 ++-- 22 files changed, 47 insertions(+), 57 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 45745a1..f38652c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -9,5 +9,5 @@ ->include(__DIR__ . '/tests') ->include(__FILE__) ->cache('./runtime/php-cs-fixer.cache') - ->allowRisky(false) + ->allowRisky(true) ->build(); diff --git a/psalm-baseline.xml b/psalm-baseline.xml index c13f338..4876dac 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -17,7 +17,7 @@ normalizedPayload]]> - payload)]]> + payload)]]> @@ -89,11 +89,6 @@ - - - - - diff --git a/psalm.xml b/psalm.xml index 53f3803..c4e4edd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -16,10 +16,5 @@ - - - - - diff --git a/src/Auth/Token.php b/src/Auth/Token.php index 3bd9f82..ab29eaf 100644 --- a/src/Auth/Token.php +++ b/src/Auth/Token.php @@ -41,12 +41,12 @@ public function __construct( $this->id = $id; $this->secretValue = $secretValue; - $this->hashedValue = hash('sha512', $secretValue); + $this->hashedValue = \hash('sha512', $secretValue); $this->createdAt = $createdAt; $this->expiresAt = $expiresAt; - $this->payload = json_encode($payload); + $this->payload = \json_encode($payload); } public function setSecretValue(string $value): void @@ -56,7 +56,7 @@ public function setSecretValue(string $value): void public function getID(): string { - return sprintf('%s:%s', $this->id, $this->secretValue); + return \sprintf('%s:%s', $this->id, $this->secretValue); } public function getHashedValue(): string @@ -76,15 +76,15 @@ public function getExpiresAt(): ?\DateTimeInterface public function getPayload(): array { - if (is_array($this->normalizedPayload)) { + if (\is_array($this->normalizedPayload)) { return $this->normalizedPayload; } - if (is_resource($this->payload)) { + if (\is_resource($this->payload)) { // postgres - $this->normalizedPayload = json_decode(stream_get_contents($this->payload), true); - } elseif (is_string($this->payload)) { - $this->normalizedPayload = json_decode($this->payload, true); + $this->normalizedPayload = \json_decode(\stream_get_contents($this->payload), true); + } elseif (\is_string($this->payload)) { + $this->normalizedPayload = \json_decode($this->payload, true); } if ($this->normalizedPayload === null) { diff --git a/src/Auth/TokenStorage.php b/src/Auth/TokenStorage.php index 6def886..97c14b0 100644 --- a/src/Auth/TokenStorage.php +++ b/src/Auth/TokenStorage.php @@ -101,6 +101,6 @@ private function issueID(): string private function randomHash(int $length): string { - return \substr(\bin2hex(random_bytes($length)), 0, $length); + return \substr(\bin2hex(\random_bytes($length)), 0, $length); } } diff --git a/src/Bootloader/DisconnectsBootloader.php b/src/Bootloader/DisconnectsBootloader.php index 5fa4891..8f672e7 100644 --- a/src/Bootloader/DisconnectsBootloader.php +++ b/src/Bootloader/DisconnectsBootloader.php @@ -17,7 +17,7 @@ final class DisconnectsBootloader extends Bootloader public function init(FinalizerInterface $finalizer, ContainerInterface $container): void { $finalizer->addFinalizer( - function (bool $terminate) use ($container): void { + static function (bool $terminate) use ($container): void { if ($terminate) { return; } diff --git a/src/Bootloader/ValidationBootloader.php b/src/Bootloader/ValidationBootloader.php index b0494bb..ff580c8 100644 --- a/src/Bootloader/ValidationBootloader.php +++ b/src/Bootloader/ValidationBootloader.php @@ -10,7 +10,7 @@ final class ValidationBootloader extends Bootloader { - public function boot(ValidatorBootloader $validation) + public function boot(ValidatorBootloader $validation): void { $validation->addChecker('entity', EntityChecker::class); } diff --git a/src/Console/Command/CycleOrm/RenderCommand.php b/src/Console/Command/CycleOrm/RenderCommand.php index a41044c..3c099f6 100644 --- a/src/Console/Command/CycleOrm/RenderCommand.php +++ b/src/Console/Command/CycleOrm/RenderCommand.php @@ -28,7 +28,7 @@ public function perform( 'color' => new OutputSchemaRenderer(OutputSchemaRenderer::FORMAT_CONSOLE_COLOR), 'plain' => new OutputSchemaRenderer(OutputSchemaRenderer::FORMAT_PLAIN_TEXT), default => throw new \InvalidArgumentException( - sprintf("Format `%s` isn't supported.", $this->argument('format')), + \sprintf("Format `%s` isn't supported.", $this->argument('format')), ), }; diff --git a/src/Console/Command/Database/ListCommand.php b/src/Console/Command/Database/ListCommand.php index 6f588c4..e092c98 100644 --- a/src/Console/Command/Database/ListCommand.php +++ b/src/Console/Command/Database/ListCommand.php @@ -65,7 +65,7 @@ public function perform(DatabaseConfig $config, DatabaseProviderInterface $dbal) } catch (\Exception $exception) { $this->renderException($grid, $header, $exception); - if ($database->getName() != end($databases)) { + if ($database->getName() != \end($databases)) { $grid->addRow(new TableSeparator()); } @@ -74,7 +74,7 @@ public function perform(DatabaseConfig $config, DatabaseProviderInterface $dbal) $header[] = 'connected'; $this->renderTables($grid, $header, $database); - if ($database->getName() != end($databases)) { + if ($database->getName() != \end($databases)) { $grid->addRow(new TableSeparator()); } } @@ -102,14 +102,14 @@ private function renderTables(Table $grid, array $header, Database $database): v { foreach ($database->getTables() as $table) { $grid->addRow( - array_merge( + \array_merge( $header, - [$table->getName(), number_format($table->count())], + [$table->getName(), \number_format($table->count())], ), ); $header = ['', '', '', '', '']; } - $header[1] && $grid->addRow(array_merge($header, ['no tables', 'no records'])); + $header[1] && $grid->addRow(\array_merge($header, ['no tables', 'no records'])); } } diff --git a/src/Console/Command/Migrate/AbstractCommand.php b/src/Console/Command/Migrate/AbstractCommand.php index 763c780..987956b 100644 --- a/src/Console/Command/Migrate/AbstractCommand.php +++ b/src/Console/Command/Migrate/AbstractCommand.php @@ -56,7 +56,7 @@ protected function verifyEnvironment(string $message = 'Confirmation is required protected function defineOptions(): array { - return array_merge( + return \array_merge( static::OPTIONS, [ ['force', 's', InputOption::VALUE_NONE, 'Skip safe environment check'], diff --git a/src/DataGrid/Writer/PostgresQueryWriter.php b/src/DataGrid/Writer/PostgresQueryWriter.php index 9a62abd..d024411 100644 --- a/src/DataGrid/Writer/PostgresQueryWriter.php +++ b/src/DataGrid/Writer/PostgresQueryWriter.php @@ -28,7 +28,7 @@ public function write(mixed $source, SpecificationInterface $specification, Comp return $source->where( $specification->getExpression(), 'ILIKE', - sprintf($specification->getPattern(), $this->fetchValue($specification->getValue())), + \sprintf($specification->getPattern(), $this->fetchValue($specification->getValue())), ); } @@ -43,7 +43,7 @@ public function write(mixed $source, SpecificationInterface $specification, Comp protected function targetAcceptable($target): bool { if ( - class_exists(SelectQuery::class) + \class_exists(SelectQuery::class) && $target instanceof SelectQuery && $target->getDriver() instanceof PostgresDriver ) { diff --git a/src/Injector/DatabaseInjector.php b/src/Injector/DatabaseInjector.php index dd3be37..21c0db7 100644 --- a/src/Injector/DatabaseInjector.php +++ b/src/Injector/DatabaseInjector.php @@ -24,7 +24,7 @@ public function createInjection(\ReflectionClass $class, ?string $context = null try { return $this->dm->database($context); } catch (DBALException $e) { - if ($context === null || !str_contains($e->getMessage(), ' no presets for ')) { + if ($context === null || !\str_contains($e->getMessage(), ' no presets for ')) { throw $e; } // get default database diff --git a/tests/src/Auth/TokenStorageTest.php b/tests/src/Auth/TokenStorageTest.php index 52ae5c0..9463943 100644 --- a/tests/src/Auth/TokenStorageTest.php +++ b/tests/src/Auth/TokenStorageTest.php @@ -13,7 +13,7 @@ final class TokenStorageTest extends BaseTest { private TokenStorage $storage; - public function testTokenShouldBeCreatedWithoutExpiration() + public function testTokenShouldBeCreatedWithoutExpiration(): void { $token = $this->storage->create(['foo' => 'bar']); @@ -23,7 +23,7 @@ public function testTokenShouldBeCreatedWithoutExpiration() $this->assertSame(['foo' => 'bar'], $token->getPayload()); } - public function testTokenShouldBeCreatedWithExpiration() + public function testTokenShouldBeCreatedWithExpiration(): void { $token = $this->storage->create(['foo' => 'bar'], $date = new \DateTimeImmutable('2010-05-05 12:34:56')); @@ -33,7 +33,7 @@ public function testTokenShouldBeCreatedWithExpiration() $this->assertSame(['foo' => 'bar'], $token->getPayload()); } - public function testTokenShouldBeLoadedById() + public function testTokenShouldBeLoadedById(): void { $token = $this->storage->create(['foo' => 'bar']); @@ -47,7 +47,7 @@ public function testTokenShouldBeLoadedById() $this->assertSame($loadedToken->getExpiresAt(), $token->getExpiresAt()); } - public function testTokenShouldBeDeleted() + public function testTokenShouldBeDeleted(): void { $token = $this->storage->create(['foo' => 'bar']); $this->storage->delete($token); diff --git a/tests/src/Auth/TokenTest.php b/tests/src/Auth/TokenTest.php index 89a2e76..712f670 100644 --- a/tests/src/Auth/TokenTest.php +++ b/tests/src/Auth/TokenTest.php @@ -42,7 +42,7 @@ public function testGetPayloadWithBadPayload(): void */ public function testGetPayloadWithBadResourcePayload(): void { - $resourcePayload = fopen('php://memory', 'r'); + $resourcePayload = \fopen('php://memory', 'r'); $token = $this->setProtectedProperty($this->buildToken(), 'payload', $resourcePayload); @@ -60,7 +60,7 @@ public function testGetPayloadWithBadResourcePayload(): void */ protected function setProtectedProperty(object $object, string $property, $value): object { - $refProjectClass = new \ReflectionClass(get_class($object)); + $refProjectClass = new \ReflectionClass(\get_class($object)); $classProperty = $refProjectClass->getProperty($property); $classProperty->setAccessible(true); $classProperty->setValue($object, $value); diff --git a/tests/src/BaseTest.php b/tests/src/BaseTest.php index f211764..4c8f7f4 100644 --- a/tests/src/BaseTest.php +++ b/tests/src/BaseTest.php @@ -45,7 +45,7 @@ public function getTestAttributes(string $attribute, ?string $method = null): ar public function rootDirectory(): string { - return dirname(__DIR__ . '/../app'); + return \dirname(__DIR__ . '/../app'); } public function defineBootloaders(): array @@ -111,8 +111,8 @@ public function getRepository(string $role): RepositoryInterface public function updateConfig(string $key, mixed $data): void { - [$config, $key] = explode('.', $key, 2); - $this->beforeBooting(static function (ConfigsInterface $configs) use ($config, $key, $data) { + [$config, $key] = \explode('.', $key, 2); + $this->beforeBooting(static function (ConfigsInterface $configs) use ($config, $key, $data): void { $configs->modify( $config, new Set($key, $data), diff --git a/tests/src/Bootloader/CycleOrmWarmedUpBootloaderTest.php b/tests/src/Bootloader/CycleOrmWarmedUpBootloaderTest.php index c76616b..95b2552 100644 --- a/tests/src/Bootloader/CycleOrmWarmedUpBootloaderTest.php +++ b/tests/src/Bootloader/CycleOrmWarmedUpBootloaderTest.php @@ -43,7 +43,7 @@ protected function setUp(): void return $heap; }); - $this->beforeBooting(static function (Container $container) use ($orm) { + $this->beforeBooting(static function (Container $container) use ($orm): void { $container->bindSingleton(ORMInterface::class, $orm); $container->bindSingleton(ORM::class, $orm); }); diff --git a/tests/src/Console/Command/CycleOrm/MigrateCommandTest.php b/tests/src/Console/Command/CycleOrm/MigrateCommandTest.php index b7af798..8854f10 100644 --- a/tests/src/Console/Command/CycleOrm/MigrateCommandTest.php +++ b/tests/src/Console/Command/CycleOrm/MigrateCommandTest.php @@ -67,7 +67,7 @@ public function testMigrationShouldBeCreatedWhenNewEntityAppeared(): void $fs = new Files(); $entityPatch = __DIR__ . '/../../../../app/Entities/Tag.php'; - file_put_contents( + \file_put_contents( $entityPatch, <<<'PHP' assertConsoleCommandOutputContainsStrings('cycle:render', ['format' => 'color'], [ '[user] :: default.users', @@ -67,7 +67,7 @@ public function testRenderInInvalidFormat(): void 'custom_typecast_handler', ], ])] - public function testRedefineSchemaDefaults() + public function testRedefineSchemaDefaults(): void { $this->assertConsoleCommandOutputContainsStrings('cycle:render', ['format' => 'plain'], [ 'Mapper: custom_mapper', diff --git a/tests/src/DataGrid/GeneratorTest.php b/tests/src/DataGrid/GeneratorTest.php index 200bcf5..7ad4bd2 100644 --- a/tests/src/DataGrid/GeneratorTest.php +++ b/tests/src/DataGrid/GeneratorTest.php @@ -38,7 +38,7 @@ public function testBasePaginate(): void 'status' => 'active', 'name' => 'Antony', ], - ], iterator_to_array($view)); + ], \iterator_to_array($view)); $this->assertNull($view->getOption(Grid::COUNT)); @@ -72,7 +72,7 @@ public function testPaginateWithCount(): void 'status' => 'active', 'name' => 'John', ], - ], iterator_to_array($view)); + ], \iterator_to_array($view)); $this->assertSame(3, $view->getOption(Grid::COUNT)); @@ -107,7 +107,7 @@ public function testDefaultWithMapping(): void $this->assertEquals([ 'John', - ], iterator_to_array($view)); + ], \iterator_to_array($view)); $this->assertSame(3, $view->getOption(Grid::COUNT)); @@ -139,7 +139,7 @@ public function testSort(): void 'Bob', 'John', 'Antony', - ], iterator_to_array($view)); + ], \iterator_to_array($view)); $this->assertSame([ 'id' => 'desc', @@ -168,7 +168,7 @@ public function testSortAsc(): void 'Antony', 'John', 'Bob', - ], iterator_to_array($view)); + ], \iterator_to_array($view)); $this->assertSame([ 'id' => 'asc', diff --git a/tests/src/DataGrid/QueryWriter/WriteSorterTest.php b/tests/src/DataGrid/QueryWriter/WriteSorterTest.php index a84b88d..3960767 100644 --- a/tests/src/DataGrid/QueryWriter/WriteSorterTest.php +++ b/tests/src/DataGrid/QueryWriter/WriteSorterTest.php @@ -120,7 +120,7 @@ public function testBinary($direction, $resultDirection = null): void ); $this->assertEqualSQL( - sprintf( + \sprintf( 'SELECT * FROM "users" ORDER BY "balance" %s, "credits" %s', $resultDirection, $resultDirection, @@ -180,7 +180,7 @@ public function testSortBinary($direction, $resultDirection = null): void ); $this->assertEqualSQL( - sprintf( + \sprintf( 'SELECT * FROM "users" ORDER BY "balance" %s, "credits" %s', $resultDirection, $resultDirection, diff --git a/tests/src/Validation/EntityCheckerTest.php b/tests/src/Validation/EntityCheckerTest.php index b09d697..7ee0242 100644 --- a/tests/src/Validation/EntityCheckerTest.php +++ b/tests/src/Validation/EntityCheckerTest.php @@ -165,14 +165,14 @@ public function badCasesProvider(): iterable 'rules' => [ 'email' => [['entity::exists', User::class, 'email', 'ignoreCase' => true, 'multiple' => true]], ], - 'entityData' => [strtoupper(self::ENTITY_PK) => [1, 2], 'email' => 'TEST@mail.com'], + 'entityData' => [\strtoupper(self::ENTITY_PK) => [1, 2], 'email' => 'TEST@mail.com'], 'exceptionText' => 'The `exists` rule doesn\'t work in multiple case insensitive mode.', ], 'pk ignore case true multiple - not found' => [ 'rules' => [ 'email' => [['entity::exists', User::class, 'email', 'ignoreCase' => true, 'multiple' => true]], ], - 'entityData' => [strtoupper(self::ENTITY_PK) => [2, 96], 'email' => 'TEST@mail.com'], + 'entityData' => [\strtoupper(self::ENTITY_PK) => [2, 96], 'email' => 'TEST@mail.com'], 'exceptionText' => 'The `exists` rule doesn\'t work in multiple case insensitive mode.', ], ]; diff --git a/tests/src/Validation/EntityCheckerTrait.php b/tests/src/Validation/EntityCheckerTrait.php index fc5d8f4..c44b68e 100644 --- a/tests/src/Validation/EntityCheckerTrait.php +++ b/tests/src/Validation/EntityCheckerTrait.php @@ -95,9 +95,9 @@ public function __construct( public function where(string $field, string $operator, Parameter $parameter): self { - $this->items = array_filter( + $this->items = \array_filter( $this->items, - fn(mixed $value) => \in_array($value[$field], (array) $parameter->getValue(), true), + static fn(mixed $value) => \in_array($value[$field], (array) $parameter->getValue(), true), ); return $this;