Skip to content
/ boot Public

Commit fdacb1c

Browse files
committed
Merge pull request #1207: Apply Spiral Code Style
1 parent 57e57e5 commit fdacb1c

File tree

78 files changed

+518
-588
lines changed

Some content is hidden

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

78 files changed

+518
-588
lines changed

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
],
3535
"require": {
3636
"php": ">=8.1",
37-
"spiral/core": "^3.14.10",
38-
"spiral/files": "^3.14.10",
39-
"spiral/config": "^3.14.10",
40-
"spiral/debug": "^3.14.10",
41-
"spiral/exceptions": "^3.14.10",
37+
"spiral/core": "^3.15",
38+
"spiral/files": "^3.15",
39+
"spiral/config": "^3.15",
40+
"spiral/debug": "^3.15",
41+
"spiral/exceptions": "^3.15",
4242
"spiral/attributes": "^2.8|^3.0",
43-
"spiral/events": "^3.14.10"
43+
"spiral/events": "^3.15"
4444
},
4545
"require-dev": {
4646
"phpunit/phpunit": "^10.1",

src/AbstractKernel.php

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

55
namespace Spiral\Boot;
66

7-
use Closure;
87
use Psr\EventDispatcher\EventDispatcherInterface;
98
use Spiral\Attribute\DispatcherScope;
109
use Spiral\Boot\Bootloader\BootloaderRegistry;
@@ -57,16 +56,16 @@ abstract class AbstractKernel implements KernelInterface
5756
*/
5857
protected array $dispatchers = [];
5958

60-
/** @var array<Closure> */
59+
/** @var array<\Closure> */
6160
private array $runningCallbacks = [];
6261

63-
/** @var array<Closure> */
62+
/** @var array<\Closure> */
6463
private array $bootingCallbacks = [];
6564

66-
/** @var array<Closure> */
65+
/** @var array<\Closure> */
6766
private array $bootedCallbacks = [];
6867

69-
/** @var array<Closure> */
68+
/** @var array<\Closure> */
7069
private array $bootstrappedCallbacks = [];
7170

7271
/**
@@ -76,7 +75,7 @@ protected function __construct(
7675
protected readonly Container $container,
7776
protected readonly ExceptionHandlerInterface $exceptionHandler,
7877
protected readonly BootloadManagerInterface $bootloader,
79-
array $directories
78+
array $directories,
8079
) {
8180
$container->bindSingleton(ExceptionHandlerInterface::class, $exceptionHandler);
8281
$container->bindSingleton(ExceptionRendererInterface::class, $exceptionHandler);
@@ -89,21 +88,13 @@ protected function __construct(
8988

9089
$container->bindSingleton(
9190
DirectoriesInterface::class,
92-
new Directories($this->mapDirectories($directories))
91+
new Directories($this->mapDirectories($directories)),
9392
);
9493

9594
$this->finalizer = new Finalizer();
9695
$container->bindSingleton(FinalizerInterface::class, $this->finalizer);
9796
}
9897

99-
/**
100-
* Terminate the application.
101-
*/
102-
public function __destruct()
103-
{
104-
$this->finalizer->finalize(true);
105-
}
106-
10798
/**
10899
* Create an application instance.
109100
*
@@ -116,7 +107,7 @@ final public static function create(
116107
bool $handleErrors = true,
117108
ExceptionHandlerInterface|string|null $exceptionHandler = null,
118109
Container $container = new Container(),
119-
BootloadManagerInterface|Autowire|null $bootloadManager = null
110+
BootloadManagerInterface|Autowire|null $bootloadManager = null,
120111
): static {
121112
$exceptionHandler ??= ExceptionHandler::class;
122113

@@ -151,21 +142,20 @@ final public static function create(
151142
$container,
152143
$exceptionHandler,
153144
$bootloadManager,
154-
$directories
145+
$directories,
155146
);
156147
}
157148

158149
/**
159150
* Run the application with given Environment
160151
*
161-
* $app = App::create([...]);
162-
* $app->booting(...);
163-
* $app->booted(...);
164-
* $app->bootstrapped(...);
165-
* $app->run(new Environment([
166-
* 'APP_ENV' => 'production'
167-
* ]));
168-
*
152+
* $app = App::create([...]);
153+
* $app->booting(...);
154+
* $app->booted(...);
155+
* $app->bootstrapped(...);
156+
* $app->run(new Environment([
157+
* 'APP_ENV' => 'production'
158+
* ]));
169159
*/
170160
public function run(?EnvironmentInterface $environment = null): ?self
171161
{
@@ -187,7 +177,7 @@ function (Container $container): void {
187177
$this->bootstrap();
188178

189179
$this->fireCallbacks($this->bootstrappedCallbacks);
190-
}
180+
},
191181
);
192182
} catch (\Throwable $e) {
193183
$this->exceptionHandler->handleGlobalException($e);
@@ -208,7 +198,7 @@ function (Container $container): void {
208198
* $kernel->getContainer()->...
209199
* });
210200
*/
211-
public function running(Closure ...$callbacks): void
201+
public function running(\Closure ...$callbacks): void
212202
{
213203
foreach ($callbacks as $callback) {
214204
$this->runningCallbacks[] = $callback;
@@ -223,7 +213,7 @@ public function running(Closure ...$callbacks): void
223213
* $kernel->getContainer()->...
224214
* });
225215
*/
226-
public function booting(Closure ...$callbacks): void
216+
public function booting(\Closure ...$callbacks): void
227217
{
228218
foreach ($callbacks as $callback) {
229219
$this->bootingCallbacks[] = $callback;
@@ -238,14 +228,13 @@ public function booting(Closure ...$callbacks): void
238228
* $kernel->getContainer()->...
239229
* });
240230
*/
241-
public function booted(Closure ...$callbacks): void
231+
public function booted(\Closure ...$callbacks): void
242232
{
243233
foreach ($callbacks as $callback) {
244234
$this->bootedCallbacks[] = $callback;
245235
}
246236
}
247237

248-
249238
/**
250239
* Register a new callback, that will be fired after framework bootstrapped.
251240
* (Before serving)
@@ -254,7 +243,7 @@ public function booted(Closure ...$callbacks): void
254243
* $kernel->getContainer()->...
255244
* });
256245
*/
257-
public function bootstrapped(Closure ...$callbacks): void
246+
public function bootstrapped(\Closure ...$callbacks): void
258247
{
259248
foreach ($callbacks as $callback) {
260249
$this->bootstrappedCallbacks[] = $callback;
@@ -314,10 +303,18 @@ public function serve(): mixed
314303
static function (DispatcherInterface $dispatcher) use ($eventDispatcher): mixed {
315304
$eventDispatcher?->dispatch(new DispatcherFound($dispatcher));
316305
return $dispatcher->serve();
317-
}
306+
},
318307
);
319308
}
320309

310+
/**
311+
* Terminate the application.
312+
*/
313+
public function __destruct()
314+
{
315+
$this->finalizer->finalize(true);
316+
}
317+
321318
/**
322319
* Bootstrap application. Must be executed before serve method.
323320
*/
@@ -376,7 +373,7 @@ private function bootload(array $bootloaders = []): void
376373
static function () use ($self): void {
377374
$self->fireCallbacks($self->bootingCallbacks);
378375
},
379-
]
376+
],
380377
);
381378

382379
$this->fireCallbacks($this->bootedCallbacks);

src/Attribute/BootloadConfig.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ public function __construct(
1515
public array $allowEnv = [],
1616
public array $denyEnv = [],
1717
public bool $override = true,
18-
) {
19-
}
18+
) {}
2019
}

src/BootloadManager/AbstractBootloadManager.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ abstract class AbstractBootloadManager implements BootloadManagerInterface
1616
{
1717
public function __construct(
1818
private readonly ScopeInterface $scope,
19-
protected readonly InitializerInterface $initializer
20-
) {
21-
}
19+
protected readonly InitializerInterface $initializer,
20+
) {}
2221

2322
public function getClasses(): array
2423
{
@@ -29,14 +28,14 @@ public function bootload(
2928
array $classes,
3029
array $bootingCallbacks = [],
3130
array $bootedCallbacks = [],
32-
bool $useConfig = true
31+
bool $useConfig = true,
3332
): void {
3433
$this->scope->runScope(
3534
[self::class => $this],
3635
function () use ($classes, $bootingCallbacks, $bootedCallbacks, $useConfig): void {
3736
/** @psalm-suppress TooManyArguments */
3837
$this->boot($classes, $bootingCallbacks, $bootedCallbacks, $useConfig);
39-
}
38+
},
4039
);
4140
}
4241

src/BootloadManager/BootloadManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public function __construct(
2020
private readonly InvokerInterface $invoker,
2121
private readonly ResolverInterface $resolver,
2222
InitializerInterface $initializer,
23-
?InvokerStrategyInterface $invokerStrategy = null
23+
?InvokerStrategyInterface $invokerStrategy = null,
2424
) {
2525
parent::__construct($scope, $initializer);
2626

2727
$this->invokerStrategy = $invokerStrategy ?? new DefaultInvokerStrategy(...$this->resolver->resolveArguments(
28-
(new \ReflectionClass(DefaultInvokerStrategy::class))->getConstructor()
28+
(new \ReflectionClass(DefaultInvokerStrategy::class))->getConstructor(),
2929
));
3030
}
3131

src/BootloadManager/Checker/BootloaderChecker.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ final class BootloaderChecker implements BootloaderCheckerInterface
1111
{
1212
public function __construct(
1313
private readonly CheckerRegistryInterface $registry = new CheckerRegistry(),
14-
) {
15-
}
14+
) {}
1615

1716
public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool
1817
{

src/BootloadManager/Checker/CanBootedChecker.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ final class CanBootedChecker implements BootloaderCheckerInterface
1212
{
1313
public function __construct(
1414
private readonly ClassesRegistry $bootloaders,
15-
) {
16-
}
15+
) {}
1716

1817
public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool
1918
{

src/BootloadManager/Checker/ConfigChecker.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ final class ConfigChecker implements BootloaderCheckerInterface
1212
{
1313
public function __construct(
1414
private readonly EnvironmentInterface $environment,
15-
) {
16-
}
15+
) {}
1716

1817
public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool
1918
{

src/BootloadManager/DefaultInvokerStrategy.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ final class DefaultInvokerStrategy implements InvokerStrategyInterface
1313
public function __construct(
1414
private readonly InitializerInterface $initializer,
1515
private readonly InvokerInterface $invoker,
16-
private readonly ResolverInterface $resolver
17-
) {
18-
}
16+
private readonly ResolverInterface $resolver,
17+
) {}
1918

2019
public function invokeBootloaders(
2120
array $classes,
2221
array $bootingCallbacks,
2322
array $bootedCallbacks,
24-
bool $useConfig = true
23+
bool $useConfig = true,
2524
): void {
2625
/** @psalm-suppress TooManyArguments */
2726
$bootloaders = \iterator_to_array($this->initializer->init($classes, $useConfig));

src/BootloadManager/Initializer.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public function __construct(
3434
protected readonly BinderInterface $binder,
3535
protected readonly ClassesRegistry $bootloaders = new ClassesRegistry(),
3636
?BootloaderCheckerInterface $checker = null,
37-
) {
38-
}
37+
) {}
3938

4039
/**
4140
* Instantiate bootloader objects and resolve dependencies
@@ -89,7 +88,7 @@ protected function initBootloader(BootloaderInterface $bootloader): iterable
8988

9089
$this->initBindings(
9190
$bootloader->defineBindings(),
92-
$bootloader->defineSingletons()
91+
$bootloader->defineSingletons(),
9392
);
9493
}
9594

@@ -121,7 +120,7 @@ protected function getDependencies(DependedInterface $bootloader): array
121120
foreach (Methods::cases() as $method) {
122121
if ($reflectionClass->hasMethod($method->value)) {
123122
$methodsDeps[] = $this->findBootloaderClassesInMethod(
124-
$reflectionClass->getMethod($method->value)
123+
$reflectionClass->getMethod($method->value),
125124
);
126125
}
127126
}
@@ -177,7 +176,7 @@ protected function initDefaultChecker(): BootloaderCheckerInterface
177176
*/
178177
private function getBootloadConfig(
179178
string|BootloaderInterface $bootloader,
180-
array|callable|BootloadConfig $config
179+
array|callable|BootloadConfig $config,
181180
): BootloadConfig {
182181
if ($config instanceof \Closure) {
183182
$config = $this->container instanceof ResolverInterface
@@ -186,7 +185,7 @@ private function getBootloadConfig(
186185
}
187186
$attr = $this->getBootloadConfigAttribute($bootloader);
188187

189-
$getArgument = static fn (string $key, bool $override, mixed $default = []): mixed => match (true) {
188+
$getArgument = static fn(string $key, bool $override, mixed $default = []): mixed => match (true) {
190189
$config instanceof BootloadConfig && $override => $config->{$key},
191190
$config instanceof BootloadConfig && !$override && \is_array($default) =>
192191
$config->{$key} + ($attr->{$key} ?? []),

0 commit comments

Comments
 (0)