Skip to content

Commit 4446383

Browse files
github-actionsgithub-actions[bot]
github-actions
authored andcommitted
style(php-cs-fixer): lint php files and fix coding standards
1 parent 07382b6 commit 4446383

22 files changed

+51
-39
lines changed

src/Bridge/Laravel/Console/Commands/Database/ListCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle(DatabaseConfig $config, DatabaseProviderInterface $dbal):
4848
$databaseArgumentValue = $this->argument('db');
4949

5050
/** @var array<string> $databases */
51-
$databases = (null !== $databaseArgumentValue)
51+
$databases = ($databaseArgumentValue !== null)
5252
? [$databaseArgumentValue]
5353
: array_keys($config->getDatabases());
5454

src/Bridge/Laravel/Console/Commands/Database/TableCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private function describeType(AbstractColumn $column): string
226226
$type .= " ({$column->getSize()})";
227227
}
228228

229-
if ('decimal' === $abstractType) {
229+
if ($abstractType === 'decimal') {
230230
$type .= " ({$column->getPrecision()}, {$column->getScale()})";
231231
}
232232

src/Bridge/Laravel/Console/Commands/Migrations/MigrateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function handle(): int
3232
$found = false;
3333
$count = $this->option('one') ? 1 : PHP_INT_MAX;
3434

35-
while (0 < $count && null !== ($migration = $this->migrator->run())) {
35+
while ($count > 0 && null !== ($migration = $this->migrator->run())) {
3636
$found = true;
3737
--$count;
3838

src/Bridge/Laravel/Console/Commands/Migrations/RollbackCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function handle(): int
3333
$found = false;
3434
$count = ! $this->option('all') ? 1 : PHP_INT_MAX;
3535
try {
36-
while (0 < $count && null !== ($migration = $this->migrator->rollback())) {
36+
while ($count > 0 && null !== ($migration = $this->migrator->rollback())) {
3737
$found = true;
3838
--$count;
3939
$this->line(

src/Bridge/Laravel/Console/Commands/Migrations/StatusCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
final class StatusCommand extends AbstractCommand
1717
{
1818
private const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
19+
1920
private const PENDING = '<fg=red>not executed yet</fg=red>';
2021

2122
protected $signature = 'cycle:migrate:status';

src/Bridge/Laravel/Providers/CycleServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function boot(): void
3838
$config = $this->app->get(IlluminateConfig::class);
3939
$warmup = $config->get('cycle.warmup');
4040

41-
if (true === $warmup) {
41+
if ($warmup === true) {
4242
/** @var CycleORM $orm */
4343
$orm = $this->app->get(ORMInterface::class);
4444
$orm->prepareServices();

src/Bridge/Laravel/Providers/Registrator.php

+7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@
77
interface Registrator
88
{
99
public const CFG_KEY = 'cycle';
10+
1011
public const CFG_KEY_DATABASE = 'cycle.database';
12+
1113
public const CFG_KEY_TOKENIZER = 'cycle.tokenizer';
14+
1215
public const CFG_KEY_ATTRIBUTES = 'cycle.attributes';
16+
1317
public const CFG_KEY_MIGRATIONS = 'cycle.migrations';
18+
1419
public const CFG_KEY_SCHEMA = 'cycle.schema';
20+
1521
public const CFG_KEY_WARMUP = 'cycle.warmup';
22+
1623
public const CFG_KEY_RELATIONS = 'cycle.customRelations';
1724
}

src/Bridge/Laravel/Rules/Exists.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
3131

3232
$count = $table->where([$this->column => $value])->count();
3333

34-
if (0 === $count) {
34+
if ($count === 0) {
3535
$fail($this->message());
3636
}
3737
}

src/Bridge/Laravel/Rules/Unique.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function validate(string $attribute, mixed $value, Closure $fail): void
3131

3232
$count = $table->where([$this->column => $value])->count();
3333

34-
if (0 < $count) {
34+
if ($count > 0) {
3535
$fail($this->message());
3636
}
3737
}

src/Bridge/Telescope/Events/Database/QueryExecuted.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ final class QueryExecuted
1313
public function __construct(public string $sql, public array $bindings, public ?float $time, public ?string $driver = null)
1414
{
1515
$this->time = $time * 1000;
16-
$this->driver = null !== $driver ? 'CycleORM/' . $driver : 'CycleORM';
16+
$this->driver = $driver !== null ? 'CycleORM/' . $driver : 'CycleORM';
1717
}
1818
}

src/Bridge/Telescope/TelescopeLogger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function log($level, $message, array $context = []): void
2121
{
2222
$this->parentLogger->log($level, $message, $context);
2323

24-
if ('info' === $level && isset($context['elapsed'])) {
24+
if ($level === 'info' && isset($context['elapsed'])) {
2525
event(
2626
new QueryExecuted(
2727
sql: $message,

src/Bridge/Telescope/Watchers/QueryWatcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function recordQuery(QueryExecuted $event): void
3232
$time = $event->time;
3333
$caller = $this->getCallerFromStackTrace();
3434

35-
if (null !== $caller) {
35+
if ($caller !== null) {
3636
Telescope::recordQuery(IncomingEntry::make([
3737
'connection' => $event->driver,
3838
'bindings' => $event->bindings,

src/Contracts/GeneratorLoader.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
interface GeneratorLoader
1010
{
1111
public const GROUP_INDEX = 'index';
12+
1213
public const GROUP_RENDER = 'render';
14+
1315
public const GROUP_POSTPROCESS = 'postprocess';
1416

1517
/**

src/Schema/Compiler.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ final class Compiler
1717
{
1818
private const EMPTY_SCHEMA = ':empty:';
1919

20+
public function __construct(
21+
private readonly mixed $schema
22+
) {
23+
}
24+
2025
public static function compile(Registry $registry, GeneratorLoader $queue): self
2126
{
2227
return new self((new CycleSchemaCompiler())->compile($registry, $queue->get()));
@@ -27,14 +32,9 @@ public static function fromMemory(CacheManager $cache): self
2732
return new self($cache->get());
2833
}
2934

30-
public function __construct(
31-
private readonly mixed $schema
32-
) {
33-
}
34-
3535
public function isEmpty(): bool
3636
{
37-
return null === $this->schema || [] === $this->schema || self::EMPTY_SCHEMA === $this->schema;
37+
return $this->schema === null || $this->schema === [] || $this->schema === self::EMPTY_SCHEMA;
3838
}
3939

4040
public function toSchema(): SchemaInterface

src/Schema/Generators/GeneratorQueue.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
final class GeneratorQueue implements GeneratorLoader
1818
{
19-
/** @var array<array<GeneratorInterface|class-string<GeneratorInterface>>> */
19+
/**
20+
* @var array<array<GeneratorInterface|class-string<GeneratorInterface>>>
21+
*/
2022
private array $generators;
2123

2224
private Container $app;

src/Testing/Constraints/HasInDatabase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function matches(mixed $other): bool
3737
try {
3838
$count = $tableInterface->where($this->data)->count();
3939

40-
return 0 < $count;
40+
return $count > 0;
4141
} catch (Throwable $e) {
4242
return false;
4343
}

src/Testing/Constraints/NotSoftDeletedInDatabase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function matches(mixed $other): bool
4242
->andWhere($this->deletedAtColumn, '=', null)
4343
->count();
4444

45-
return 0 < $count;
45+
return $count > 0;
4646
} catch (Throwable $e) {
4747
return false;
4848
}

src/Testing/Constraints/SoftDeletedInDatabase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function matches(mixed $other): bool
4242
->andWhere($this->deletedAtColumn, '!=', null)
4343
->count();
4444

45-
return 0 < $count;
45+
return $count > 0;
4646
} catch (Throwable $e) {
4747
return false;
4848
}

tests/app/Entities/Footprint.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ final class Footprint implements JsonSerializable, Stringable
2121

2222
private readonly string $realm;
2323

24+
private function __construct(UserId $id, string $party, string $realm)
25+
{
26+
$this->id = $id;
27+
$this->party = $party;
28+
$this->realm = $realm;
29+
}
30+
2431
public static function empty(string $authorizedParty = 'guest-party', string $realm = 'guest-realm'): self
2532
{
2633
return new self(UserId::create(Uuid::NIL), $authorizedParty, $realm);
@@ -86,11 +93,4 @@ public function __toString(): string
8693
{
8794
return json_encode($this->toArray(), JSON_THROW_ON_ERROR);
8895
}
89-
90-
private function __construct(UserId $id, string $party, string $realm)
91-
{
92-
$this->id = $id;
93-
$this->party = $party;
94-
$this->realm = $realm;
95-
}
9696
}

tests/app/Entities/Signature.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class Signature
2525
#[Column(type: 'json', nullable: true, typecast: [Footprint::class, 'castValue'])]
2626
private ?Footprint $by = null;
2727

28+
public function __construct(?DateTimeImmutable $at, ?Footprint $by)
29+
{
30+
$this->at = $at;
31+
$this->by = $by;
32+
}
33+
2834
public static function forGuest(): self
2935
{
3036
return new self(new DateTimeImmutable(), Footprint::empty());
@@ -78,10 +84,4 @@ public function toArray(): array
7884
'by' => $this->by?->toArray(),
7985
];
8086
}
81-
82-
public function __construct(?DateTimeImmutable $at, ?Footprint $by)
83-
{
84-
$this->at = $at;
85-
$this->by = $by;
86-
}
8787
}

tests/app/Entities/UserId.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ final class UserId implements Stringable
1111
{
1212
private readonly string $id;
1313

14+
private function __construct(string $id)
15+
{
16+
$this->id = $id;
17+
}
18+
1419
public static function create(string $userId): self
1520
{
1621
return new self($userId);
@@ -35,9 +40,4 @@ public function __toString(): string
3540
{
3641
return $this->toString();
3742
}
38-
39-
private function __construct(string $id)
40-
{
41-
$this->id = $id;
42-
}
4343
}

tests/src/Bridge/Laravel/LoggerFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function it_should_fire_query_executed_event_when_query_is_logged(): void
7878

7979
// Assert that the QueryExecuted event was dispatched
8080
Event::assertDispatched(QueryExecuted::class, function ($event) {
81-
return 'SELECT * FROM users' === $event->sql;
81+
return $event->sql === 'SELECT * FROM users';
8282
});
8383
}
8484

0 commit comments

Comments
 (0)