Skip to content

Commit

Permalink
Update code style (apply risky rules)
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Feb 7, 2025
1 parent 2439048 commit 124ccdf
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
->include(__DIR__ . '/tests')
->include(__FILE__)
->cache('./runtime/php-cs-fixer.cache')
->allowRisky(false)
->allowRisky(true)
->build();
16 changes: 8 additions & 8 deletions src/Auth/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/TokenStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Bootloader/DisconnectsBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Bootloader/ValidationBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/CycleOrm/RenderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
),
};

Expand Down
10 changes: 5 additions & 5 deletions src/Console/Command/Database/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand All @@ -74,7 +74,7 @@ public function perform(DatabaseConfig $config, DatabaseProviderInterface $dbal)

$header[] = '<info>connected</info>';
$this->renderTables($grid, $header, $database);
if ($database->getName() != end($databases)) {
if ($database->getName() != \end($databases)) {
$grid->addRow(new TableSeparator());
}
}
Expand Down Expand Up @@ -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']));
}
}
2 changes: 1 addition & 1 deletion src/Console/Command/Migrate/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
4 changes: 2 additions & 2 deletions src/DataGrid/Writer/PostgresQueryWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
);
}

Expand All @@ -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
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Injector/DatabaseInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/src/Auth/TokenStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand All @@ -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'));

Expand All @@ -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']);

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Auth/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/src/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Bootloader/CycleOrmWarmedUpBootloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Console/Command/CycleOrm/MigrateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
<?php
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Console/Command/CycleOrm/RenderCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testRenderInPHPFormat(): void
'custom_typecast_handler',
],
])]
public function testRenderInColorFormat()
public function testRenderInColorFormat(): void
{
$this->assertConsoleCommandOutputContainsStrings('cycle:render', ['format' => 'color'], [
'[user] :: default.users',
Expand All @@ -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',
Expand Down
10 changes: 5 additions & 5 deletions tests/src/DataGrid/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -139,7 +139,7 @@ public function testSort(): void
'Bob',
'John',
'Antony',
], iterator_to_array($view));
], \iterator_to_array($view));

$this->assertSame([
'id' => 'desc',
Expand Down Expand Up @@ -168,7 +168,7 @@ public function testSortAsc(): void
'Antony',
'John',
'Bob',
], iterator_to_array($view));
], \iterator_to_array($view));

$this->assertSame([
'id' => 'asc',
Expand Down
4 changes: 2 additions & 2 deletions tests/src/DataGrid/QueryWriter/WriteSorterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Validation/EntityCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
],
];
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Validation/EntityCheckerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 124ccdf

Please sign in to comment.