@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | SampleBootWithMethodBoot::class, |
27 | 27 | SampleBoot::class, |
28 | 28 | ], [ |
29 | - static function(Container $container, SampleBoot $boot) { |
|
29 | + static function (Container $container, SampleBoot $boot){ |
|
30 | 30 | $container->bind('efg', $boot); |
31 | 31 | } |
32 | 32 | ], [ |
33 | - static function(Container $container, SampleBoot $boot) { |
|
33 | + static function (Container $container, SampleBoot $boot){ |
|
34 | 34 | $container->bind('ghi', $boot); |
35 | 35 | } |
36 | 36 | ]); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $bootloader = $this->getBootloadManager(); |
82 | 82 | |
83 | 83 | $bootloader->bootload([ |
84 | - new class () extends Bootloader { |
|
84 | + new class () extends Bootloader{ |
|
85 | 85 | public const BINDINGS = ['abc' => self::class]; |
86 | 86 | public const SINGLETONS = ['single' => self::class]; |
87 | 87 |
@@ -26,11 +26,13 @@ discard block |
||
26 | 26 | SampleBootWithMethodBoot::class, |
27 | 27 | SampleBoot::class, |
28 | 28 | ], [ |
29 | - static function(Container $container, SampleBoot $boot) { |
|
29 | + static function(Container $container, SampleBoot $boot) |
|
30 | + { |
|
30 | 31 | $container->bind('efg', $boot); |
31 | 32 | } |
32 | 33 | ], [ |
33 | - static function(Container $container, SampleBoot $boot) { |
|
34 | + static function(Container $container, SampleBoot $boot) |
|
35 | + { |
|
34 | 36 | $container->bind('ghi', $boot); |
35 | 37 | } |
36 | 38 | ]); |
@@ -81,7 +83,8 @@ discard block |
||
81 | 83 | $bootloader = $this->getBootloadManager(); |
82 | 84 | |
83 | 85 | $bootloader->bootload([ |
84 | - new class () extends Bootloader { |
|
86 | + new class () extends Bootloader |
|
87 | + { |
|
85 | 88 | public const BINDINGS = ['abc' => self::class]; |
86 | 89 | public const SINGLETONS = ['single' => self::class]; |
87 | 90 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | #[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor] |
11 | 11 | final class TargetWorker extends BootloaderRules |
12 | 12 | { |
13 | - public function __construct(array|string $workers) |
|
13 | + public function __construct(array | string $workers) |
|
14 | 14 | { |
15 | 15 | parent::__construct(allowEnv: ['RR_MODE' => $workers]); |
16 | 16 | } |
@@ -15,6 +15,6 @@ |
||
15 | 15 | public array $allowEnv = [], |
16 | 16 | public array $denyEnv = [], |
17 | 17 | public bool $override = true, |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | private readonly InitializerInterface $initializer, |
15 | 15 | private readonly InvokerInterface $invoker, |
16 | 16 | private readonly ResolverInterface $resolver |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function invokeBootloaders( |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | /** @psalm-suppress TooManyArguments */ |
27 | 27 | $bootloaders = \iterator_to_array($this->initializer->init($classes, $useRules)); |
28 | 28 | |
29 | - foreach ($bootloaders as $data) { |
|
29 | + foreach ($bootloaders as $data){ |
|
30 | 30 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); |
31 | 31 | } |
32 | 32 | |
33 | 33 | $this->fireCallbacks($bootingCallbacks); |
34 | 34 | |
35 | - foreach ($bootloaders as $data) { |
|
35 | + foreach ($bootloaders as $data){ |
|
36 | 36 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); |
37 | 37 | } |
38 | 38 | |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void |
43 | 43 | { |
44 | 44 | $refl = new \ReflectionClass($bootloader); |
45 | - if (!$refl->hasMethod($method->value)) { |
|
45 | + if (!$refl->hasMethod($method->value)){ |
|
46 | 46 | return; |
47 | 47 | } |
48 | 48 | |
49 | 49 | $method = $refl->getMethod($method->value); |
50 | 50 | |
51 | 51 | $args = $this->resolver->resolveArguments($method); |
52 | - if (!isset($args['boot'])) { |
|
52 | + if (!isset($args['boot'])){ |
|
53 | 53 | $args['boot'] = $options; |
54 | 54 | } |
55 | 55 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private function fireCallbacks(array $callbacks): void |
63 | 63 | { |
64 | - foreach ($callbacks as $callback) { |
|
64 | + foreach ($callbacks as $callback){ |
|
65 | 65 | $this->invoker->invoke($callback); |
66 | 66 | } |
67 | 67 | } |
@@ -26,13 +26,15 @@ discard block |
||
26 | 26 | /** @psalm-suppress TooManyArguments */ |
27 | 27 | $bootloaders = \iterator_to_array($this->initializer->init($classes, $useRules)); |
28 | 28 | |
29 | - foreach ($bootloaders as $data) { |
|
29 | + foreach ($bootloaders as $data) |
|
30 | + { |
|
30 | 31 | $this->invokeBootloader($data['bootloader'], Methods::INIT, $data['options']); |
31 | 32 | } |
32 | 33 | |
33 | 34 | $this->fireCallbacks($bootingCallbacks); |
34 | 35 | |
35 | - foreach ($bootloaders as $data) { |
|
36 | + foreach ($bootloaders as $data) |
|
37 | + { |
|
36 | 38 | $this->invokeBootloader($data['bootloader'], Methods::BOOT, $data['options']); |
37 | 39 | } |
38 | 40 | |
@@ -42,14 +44,16 @@ discard block |
||
42 | 44 | private function invokeBootloader(BootloaderInterface $bootloader, Methods $method, array $options): void |
43 | 45 | { |
44 | 46 | $refl = new \ReflectionClass($bootloader); |
45 | - if (!$refl->hasMethod($method->value)) { |
|
47 | + if (!$refl->hasMethod($method->value)) |
|
48 | + { |
|
46 | 49 | return; |
47 | 50 | } |
48 | 51 | |
49 | 52 | $method = $refl->getMethod($method->value); |
50 | 53 | |
51 | 54 | $args = $this->resolver->resolveArguments($method); |
52 | - if (!isset($args['boot'])) { |
|
55 | + if (!isset($args['boot'])) |
|
56 | + { |
|
53 | 57 | $args['boot'] = $options; |
54 | 58 | } |
55 | 59 | |
@@ -61,7 +65,8 @@ discard block |
||
61 | 65 | */ |
62 | 66 | private function fireCallbacks(array $callbacks): void |
63 | 67 | { |
64 | - foreach ($callbacks as $callback) { |
|
68 | + foreach ($callbacks as $callback) |
|
69 | + { |
|
65 | 70 | $this->invoker->invoke($callback); |
66 | 71 | } |
67 | 72 | } |
@@ -12,5 +12,5 @@ |
||
12 | 12 | /** |
13 | 13 | * @param class-string<BootloaderInterface>|BootloaderInterface $bootloader |
14 | 14 | */ |
15 | - public function canInitialize(string|BootloaderInterface $bootloader, ?BootloaderRules $rules = null): bool; |
|
15 | + public function canInitialize(string | BootloaderInterface $bootloader, ?BootloaderRules $rules = null): bool; |
|
16 | 16 | } |
@@ -12,29 +12,29 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly EnvironmentInterface $environment, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
|
18 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloaderRules $rules = null): bool |
|
19 | 19 | { |
20 | - if ($rules === null) { |
|
20 | + if ($rules === null){ |
|
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | |
24 | - if (!$rules->enabled) { |
|
24 | + if (!$rules->enabled){ |
|
25 | 25 | return false; |
26 | 26 | } |
27 | 27 | |
28 | - foreach ($rules->denyEnv as $env => $denyValues) { |
|
28 | + foreach ($rules->denyEnv as $env => $denyValues){ |
|
29 | 29 | $value = $this->environment->get($env); |
30 | - if ($value !== null && \in_array($value, (array) $denyValues, true)) { |
|
30 | + if ($value !== null && \in_array($value, (array)$denyValues, true)){ |
|
31 | 31 | return false; |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - foreach ($rules->allowEnv as $env => $allowValues) { |
|
35 | + foreach ($rules->allowEnv as $env => $allowValues){ |
|
36 | 36 | $value = $this->environment->get($env); |
37 | - if ($value === null || !\in_array($value, (array) $allowValues, true)) { |
|
37 | + if ($value === null || !\in_array($value, (array)$allowValues, true)){ |
|
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | } |
@@ -17,24 +17,30 @@ |
||
17 | 17 | |
18 | 18 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
19 | 19 | { |
20 | - if ($rules === null) { |
|
20 | + if ($rules === null) |
|
21 | + { |
|
21 | 22 | return true; |
22 | 23 | } |
23 | 24 | |
24 | - if (!$rules->enabled) { |
|
25 | + if (!$rules->enabled) |
|
26 | + { |
|
25 | 27 | return false; |
26 | 28 | } |
27 | 29 | |
28 | - foreach ($rules->denyEnv as $env => $denyValues) { |
|
30 | + foreach ($rules->denyEnv as $env => $denyValues) |
|
31 | + { |
|
29 | 32 | $value = $this->environment->get($env); |
30 | - if ($value !== null && \in_array($value, (array) $denyValues, true)) { |
|
33 | + if ($value !== null && \in_array($value, (array) $denyValues, true)) |
|
34 | + { |
|
31 | 35 | return false; |
32 | 36 | } |
33 | 37 | } |
34 | 38 | |
35 | - foreach ($rules->allowEnv as $env => $allowValues) { |
|
39 | + foreach ($rules->allowEnv as $env => $allowValues) |
|
40 | + { |
|
36 | 41 | $value = $this->environment->get($env); |
37 | - if ($value === null || !\in_array($value, (array) $allowValues, true)) { |
|
42 | + if ($value === null || !\in_array($value, (array) $allowValues, true)) |
|
43 | + { |
|
38 | 44 | return false; |
39 | 45 | } |
40 | 46 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | /** |
14 | 14 | * @throws ClassNotFoundException |
15 | 15 | */ |
16 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
|
16 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloaderRules $rules = null): bool |
|
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)){ |
|
19 | 19 | return true; |
20 | 20 | } |
21 | 21 | |
22 | - if (!\class_exists($bootloader)) { |
|
22 | + if (!\class_exists($bootloader)){ |
|
23 | 23 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` is not exist.', $bootloader)); |
24 | 24 | } |
25 | 25 |
@@ -15,11 +15,13 @@ |
||
15 | 15 | */ |
16 | 16 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
17 | 17 | { |
18 | - if (!\is_string($bootloader)) { |
|
18 | + if (!\is_string($bootloader)) |
|
19 | + { |
|
19 | 20 | return true; |
20 | 21 | } |
21 | 22 | |
22 | - if (!\class_exists($bootloader)) { |
|
23 | + if (!\class_exists($bootloader)) |
|
24 | + { |
|
23 | 25 | throw new ClassNotFoundException(\sprintf('Bootloader class `%s` is not exist.', $bootloader)); |
24 | 26 | } |
25 | 27 |
@@ -11,13 +11,13 @@ |
||
11 | 11 | { |
12 | 12 | public function __construct( |
13 | 13 | private readonly CheckerRegistryInterface $registry = new CheckerRegistry(), |
14 | - ) { |
|
14 | + ){ |
|
15 | 15 | } |
16 | 16 | |
17 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
|
17 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloaderRules $rules = null): bool |
|
18 | 18 | { |
19 | - foreach ($this->registry->getCheckers() as $checker) { |
|
20 | - if (!$checker->canInitialize($bootloader, $rules)) { |
|
19 | + foreach ($this->registry->getCheckers() as $checker){ |
|
20 | + if (!$checker->canInitialize($bootloader, $rules)){ |
|
21 | 21 | return false; |
22 | 22 | } |
23 | 23 | } |
@@ -16,8 +16,10 @@ |
||
16 | 16 | |
17 | 17 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
18 | 18 | { |
19 | - foreach ($this->registry->getCheckers() as $checker) { |
|
20 | - if (!$checker->canInitialize($bootloader, $rules)) { |
|
19 | + foreach ($this->registry->getCheckers() as $checker) |
|
20 | + { |
|
21 | + if (!$checker->canInitialize($bootloader, $rules)) |
|
22 | + { |
|
21 | 23 | return false; |
22 | 24 | } |
23 | 25 | } |
@@ -12,10 +12,10 @@ |
||
12 | 12 | { |
13 | 13 | public function __construct( |
14 | 14 | private readonly ClassesRegistry $bootloaders, |
15 | - ) { |
|
15 | + ){ |
|
16 | 16 | } |
17 | 17 | |
18 | - public function canInitialize(BootloaderInterface|string $bootloader, ?BootloaderRules $rules = null): bool |
|
18 | + public function canInitialize(BootloaderInterface | string $bootloader, ?BootloaderRules $rules = null): bool |
|
19 | 19 | { |
20 | 20 | $ref = new \ReflectionClass($bootloader); |
21 | 21 |