Skip to content

Commit 0c7a830

Browse files
committed
Merge pull request #1207: Apply Spiral Code Style
1 parent 594a395 commit 0c7a830

File tree

80 files changed

+504
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+504
-583
lines changed

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"require": {
3636
"php": ">=8.1",
3737
"ext-json": "*",
38-
"spiral/core": "^3.14.10",
39-
"spiral/hmvc": "^3.14.10",
40-
"spiral/serializer": "^3.14.10",
41-
"spiral/snapshots": "^3.14.10",
42-
"spiral/telemetry": "^3.14.10",
43-
"spiral/tokenizer": "^3.14.10",
38+
"spiral/core": "^3.15",
39+
"spiral/hmvc": "^3.15",
40+
"spiral/serializer": "^3.15",
41+
"spiral/snapshots": "^3.15",
42+
"spiral/telemetry": "^3.15",
43+
"spiral/tokenizer": "^3.15",
4444
"spiral/attributes": "^2.8|^3.0",
4545
"doctrine/inflector": "^1.4|^2.0",
4646
"ramsey/uuid": "^4.2.3",
@@ -59,7 +59,7 @@
5959
"require-dev": {
6060
"phpunit/phpunit": "^10.1",
6161
"mockery/mockery": "^1.5",
62-
"spiral/boot": "^3.14.10",
62+
"spiral/boot": "^3.15",
6363
"vimeo/psalm": "^5.9"
6464
},
6565
"extra": {

src/Attribute/JobHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
class JobHandler
2222
{
2323
public function __construct(
24-
public readonly string $type
25-
) {
26-
}
24+
public readonly string $type,
25+
) {}
2726
}

src/Attribute/Queueable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,5 @@
2020
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
2121
final class Queueable
2222
{
23-
public function __construct(public ?string $queue = null)
24-
{
25-
}
23+
public function __construct(public ?string $queue = null) {}
2624
}

src/Attribute/RetryPolicy.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,21 @@
2525
class RetryPolicy
2626
{
2727
/**
28-
* @param 0|positive-int $maxAttempts
28+
* @param int<0, max> $maxAttempts
2929
* @param positive-int $delay in seconds.
3030
*/
3131
public function __construct(
3232
protected readonly int $maxAttempts = 3,
3333
protected readonly int $delay = 1,
34-
protected readonly float $multiplier = 1
35-
) {
36-
}
34+
protected readonly float $multiplier = 1,
35+
) {}
3736

3837
public function getRetryPolicy(): RetryPolicyInterface
3938
{
4039
return new Policy(
4140
maxAttempts: $this->maxAttempts,
4241
delay: $this->delay,
43-
multiplier: $this->multiplier
42+
multiplier: $this->multiplier,
4443
);
4544
}
4645
}

src/Attribute/Serializer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
class Serializer
2222
{
2323
public function __construct(
24-
public readonly string $serializer
25-
) {
26-
}
24+
public readonly string $serializer,
25+
) {}
2726
}

src/Bootloader/QueueBootloader.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Spiral\Boot\Bootloader\Bootloader;
1111
use Spiral\Config\ConfiguratorInterface;
1212
use Spiral\Config\Patch\Append;
13-
use Spiral\Core\{BinderInterface, CompatiblePipelineBuilder, FactoryInterface, InterceptableCore, InterceptorPipeline};
13+
use Spiral\Core\{BinderInterface, CompatiblePipelineBuilder, FactoryInterface};
1414
use Spiral\Core\Container\Autowire;
1515
use Spiral\Core\CoreInterceptorInterface;
1616
use Spiral\Queue\JobHandlerLocatorListener;
@@ -42,7 +42,6 @@ final class QueueBootloader extends Bootloader
4242
TokenizerListenerBootloader::class,
4343
TelemetryBootloader::class,
4444
];
45-
4645
protected const SINGLETONS = [
4746
HandlerRegistryInterface::class => QueueRegistry::class,
4847
SerializerRegistryInterface::class => QueueRegistry::class,
@@ -55,8 +54,7 @@ final class QueueBootloader extends Bootloader
5554

5655
public function __construct(
5756
private readonly ConfiguratorInterface $config,
58-
) {
59-
}
57+
) {}
6058

6159
public function init(
6260
ContainerInterface $container,
@@ -86,7 +84,7 @@ public function init(
8684
public function boot(
8785
TokenizerListenerRegistryInterface $listenerRegistry,
8886
JobHandlerLocatorListener $jobHandlerLocator,
89-
SerializerLocatorListener $serializerLocator
87+
SerializerLocatorListener $serializerLocator,
9088
): void {
9189
$listenerRegistry->addListener($jobHandlerLocator);
9290
$listenerRegistry->addListener($serializerLocator);

src/Config/QueueConfig.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getAliases(): array
5151
*/
5252
public function getConsumeInterceptors(): array
5353
{
54-
return (array)($this->config['interceptors']['consume'] ?? []);
54+
return (array) ($this->config['interceptors']['consume'] ?? []);
5555
}
5656

5757
/**
@@ -61,7 +61,7 @@ public function getConsumeInterceptors(): array
6161
*/
6262
public function getPushInterceptors(): array
6363
{
64-
return (array)($this->config['interceptors']['push'] ?? []);
64+
return (array) ($this->config['interceptors']['push'] ?? []);
6565
}
6666

6767
/**
@@ -82,7 +82,7 @@ public function getDefaultDriver(): string
8282
*/
8383
public function getDriverAliases(): array
8484
{
85-
return (array)($this->config['driverAliases'] ?? []);
85+
return (array) ($this->config['driverAliases'] ?? []);
8686
}
8787

8888
/**
@@ -101,7 +101,7 @@ public function getConnections(?string $driver = null): array
101101
if (isset($driverAliases[$driver])) {
102102
if (!\is_string($this->config['driverAliases'][$driver])) {
103103
throw new InvalidArgumentException(
104-
\sprintf('Driver alias for `%s` value must be a string', $driver)
104+
\sprintf('Driver alias for `%s` value must be a string', $driver),
105105
);
106106
}
107107

@@ -140,7 +140,7 @@ public function getConnection(string $name): array
140140

141141
if (!\is_string($driver)) {
142142
throw new InvalidArgumentException(
143-
\sprintf('Driver for queue connection `%s` value must be a string', $name)
143+
\sprintf('Driver for queue connection `%s` value must be a string', $name),
144144
);
145145
}
146146

@@ -150,7 +150,7 @@ public function getConnection(string $name): array
150150

151151
if (!\is_string($connection['driver'])) {
152152
throw new InvalidArgumentException(
153-
\sprintf('Driver alias for queue connection `%s` value must be a string', $name)
153+
\sprintf('Driver alias for queue connection `%s` value must be a string', $name),
154154
);
155155
}
156156

@@ -162,12 +162,12 @@ public function getConnection(string $name): array
162162
*/
163163
public function getRegistryHandlers(): array
164164
{
165-
return (array)($this->config['registry']['handlers'] ?? []);
165+
return (array) ($this->config['registry']['handlers'] ?? []);
166166
}
167167

168168
public function getRegistrySerializers(): array
169169
{
170-
return (array)($this->config['registry']['serializers'] ?? []);
170+
return (array) ($this->config['registry']['serializers'] ?? []);
171171
}
172172

173173
/**

src/ContainerRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class ContainerRegistry implements HandlerRegistryInterface
1515
private readonly Inflector $inflector;
1616

1717
public function __construct(
18-
private readonly ContainerInterface $container
18+
private readonly ContainerInterface $container,
1919
) {
2020
$this->inflector = (new InflectorFactory())->build();
2121
}
@@ -38,7 +38,7 @@ public function getHandler(string $jobType): HandlerInterface
3838
private function className(string $jobType): string
3939
{
4040
$names = \explode('.', $jobType);
41-
$names = \array_map(fn (string $value) => $this->inflector->classify($value), $names);
41+
$names = \array_map(fn(string $value): string => $this->inflector->classify($value), $names);
4242

4343
return \implode('\\', $names);
4444
}

src/Core/QueueInjector.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Spiral\Queue\Core;
66

7-
use ReflectionClass;
87
use Spiral\Core\Container\InjectorInterface;
98
use Spiral\Core\Exception\Container\ContainerException;
109
use Spiral\Queue\Exception\InvalidArgumentException;
@@ -17,11 +16,10 @@
1716
final class QueueInjector implements InjectorInterface
1817
{
1918
public function __construct(
20-
private readonly QueueConnectionProviderInterface $queueManager
21-
) {
22-
}
19+
private readonly QueueConnectionProviderInterface $queueManager,
20+
) {}
2321

24-
public function createInjection(ReflectionClass $class, ?string $context = null): QueueInterface
22+
public function createInjection(\ReflectionClass $class, ?string $context = null): QueueInterface
2523
{
2624
try {
2725
if ($context === null) {

src/Driver/SyncDriver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,16 @@ final class SyncDriver implements QueueInterface
1919
use QueueTrait;
2020

2121
public function __construct(
22-
private readonly Handler $coreHandler
23-
) {
24-
}
22+
private readonly Handler $coreHandler,
23+
) {}
2524

26-
/** @inheritdoc */
2725
public function push(string $name, mixed $payload = [], ?OptionsInterface $options = null): string
2826
{
2927
if ($options !== null && $options->getDelay()) {
3028
\sleep($options->getDelay());
3129
}
3230

33-
$id = (string)Uuid::uuid4();
31+
$id = (string) Uuid::uuid4();
3432

3533
$this->coreHandler->handle(
3634
name: $name,

0 commit comments

Comments
 (0)