@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use DestructorTrait; |
20 | 20 | |
21 | 21 | private State $state; |
22 | - private FactoryInterface|Factory $factory; |
|
22 | + private FactoryInterface | Factory $factory; |
|
23 | 23 | private Scope $scope; |
24 | 24 | |
25 | 25 | public function __construct(Registry $constructor) |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * @throws ContainerException |
50 | 50 | * @throws \Throwable |
51 | 51 | */ |
52 | - public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
|
52 | + public function get(string | Autowire $id, \Stringable | string | null $context = null): mixed |
|
53 | 53 | { |
54 | - if ($id instanceof Autowire) { |
|
54 | + if ($id instanceof Autowire){ |
|
55 | 55 | return $id->resolve($this->factory); |
56 | 56 | } |
57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | public function has(string $id): bool |
63 | 63 | { |
64 | - if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) { |
|
64 | + if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)){ |
|
65 | 65 | return true; |
66 | 66 | } |
67 | 67 |
@@ -51,7 +51,8 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function get(string|Autowire $id, \Stringable|string|null $context = null): mixed |
53 | 53 | { |
54 | - if ($id instanceof Autowire) { |
|
54 | + if ($id instanceof Autowire) |
|
55 | + { |
|
55 | 56 | return $id->resolve($this->factory); |
56 | 57 | } |
57 | 58 | |
@@ -61,7 +62,8 @@ discard block |
||
61 | 62 | |
62 | 63 | public function has(string $id): bool |
63 | 64 | { |
64 | - if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) { |
|
65 | + if (\array_key_exists($id, $this->state->bindings) || \array_key_exists($id, $this->state->singletons)) |
|
66 | + { |
|
65 | 67 | return true; |
66 | 68 | } |
67 | 69 |
@@ -32,35 +32,35 @@ |
||
32 | 32 | $available = $config->getDeclarations(); |
33 | 33 | |
34 | 34 | $i = 0; |
35 | - foreach ($available as $name) { |
|
36 | - $command = 'create:' . $name; |
|
35 | + foreach ($available as $name){ |
|
36 | + $command = 'create:'.$name; |
|
37 | 37 | |
38 | - if (!$console->getApplication()->has($command)) { |
|
38 | + if (!$console->getApplication()->has($command)){ |
|
39 | 39 | continue; |
40 | 40 | } |
41 | 41 | |
42 | 42 | $command = $console->getApplication()->get($command); |
43 | 43 | |
44 | - if ($i > 0) { |
|
44 | + if ($i > 0){ |
|
45 | 45 | $table->addRow(new TableSeparator()); |
46 | 46 | } |
47 | 47 | $declaration = $config->getDeclaration($name); |
48 | 48 | |
49 | 49 | $options = []; |
50 | - foreach ($declaration['options'] ?? [] as $key => $value) { |
|
51 | - $options[] = $key . ': <fg=yellow>' . \json_encode(\str_replace($rootDir, '', $value)) . '</>'; |
|
50 | + foreach ($declaration['options'] ?? [] as $key => $value){ |
|
51 | + $options[] = $key.': <fg=yellow>'.\json_encode(\str_replace($rootDir, '', $value)).'</>'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | $file = \str_replace($rootDir, '', $config->classFilename($name, $this->name)); |
55 | 55 | $namespace = $config->classNamespace($name, $this->name); |
56 | 56 | $table->addRow([ |
57 | - $command->getName() . "\n<fg=gray>{$command->getDescription()}</>", |
|
57 | + $command->getName()."\n<fg=gray>{$command->getDescription()}</>", |
|
58 | 58 | <<<TARGET |
59 | 59 | path: <fg=green>/$file</> |
60 | 60 | namespace: <fg=yellow>$namespace</> |
61 | 61 | TARGET |
62 | 62 | . |
63 | - ($options !== [] ? "\n" . \implode("\n", $options) : ''), |
|
63 | + ($options !== [] ? "\n".\implode("\n", $options) : ''), |
|
64 | 64 | ]); |
65 | 65 | |
66 | 66 | $i++; |
@@ -32,22 +32,26 @@ |
||
32 | 32 | $available = $config->getDeclarations(); |
33 | 33 | |
34 | 34 | $i = 0; |
35 | - foreach ($available as $name) { |
|
35 | + foreach ($available as $name) |
|
36 | + { |
|
36 | 37 | $command = 'create:' . $name; |
37 | 38 | |
38 | - if (!$console->getApplication()->has($command)) { |
|
39 | + if (!$console->getApplication()->has($command)) |
|
40 | + { |
|
39 | 41 | continue; |
40 | 42 | } |
41 | 43 | |
42 | 44 | $command = $console->getApplication()->get($command); |
43 | 45 | |
44 | - if ($i > 0) { |
|
46 | + if ($i > 0) |
|
47 | + { |
|
45 | 48 | $table->addRow(new TableSeparator()); |
46 | 49 | } |
47 | 50 | $declaration = $config->getDeclaration($name); |
48 | 51 | |
49 | 52 | $options = []; |
50 | - foreach ($declaration['options'] ?? [] as $key => $value) { |
|
53 | + foreach ($declaration['options'] ?? [] as $key => $value) |
|
54 | + { |
|
51 | 55 | $options[] = $key . ': <fg=yellow>' . \json_encode(\str_replace($rootDir, '', $value)) . '</>'; |
52 | 56 | } |
53 | 57 |
@@ -58,7 +58,7 @@ |
||
58 | 58 | <<<TARGET |
59 | 59 | path: <fg=green>/$file</> |
60 | 60 | namespace: <fg=yellow>$namespace</> |
61 | -TARGET |
|
61 | +target |
|
62 | 62 | . |
63 | 63 | ($options !== [] ? "\n" . \implode("\n", $options) : ''), |
64 | 64 | ]); |
@@ -12,11 +12,11 @@ |
||
12 | 12 | public function __construct( |
13 | 13 | string $interface, |
14 | 14 | bool $singleton = false, |
15 | - private readonly string|\BackedEnum|null $scope = null, |
|
15 | + private readonly string | \BackedEnum | null $scope = null, |
|
16 | 16 | private readonly ?string $version = null, |
17 | 17 | private readonly ?string $message = null, |
18 | - ) { |
|
19 | - if (($scope === null || $version === null) && $message === null) { |
|
18 | + ){ |
|
19 | + if (($scope === null || $version === null) && $message === null){ |
|
20 | 20 | throw new \InvalidArgumentException('Scope and version or custom message must be provided.'); |
21 | 21 | } |
22 | 22 |
@@ -16,7 +16,8 @@ |
||
16 | 16 | private readonly ?string $version = null, |
17 | 17 | private readonly ?string $message = null, |
18 | 18 | ) { |
19 | - if (($scope === null || $version === null) && $message === null) { |
|
19 | + if (($scope === null || $version === null) && $message === null) |
|
20 | + { |
|
20 | 21 | throw new \InvalidArgumentException('Scope and version or custom message must be provided.'); |
21 | 22 | } |
22 | 23 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $option->checkScope = true; |
32 | 32 | yield [$option]; |
33 | 33 | |
34 | - $option = new class extends Options { |
|
34 | + $option = new class extends Options{ |
|
35 | 35 | public int $customOption = 3; |
36 | 36 | }; |
37 | 37 | $option->customOption = 5; |
@@ -31,7 +31,8 @@ |
||
31 | 31 | $option->checkScope = true; |
32 | 32 | yield [$option]; |
33 | 33 | |
34 | - $option = new class extends Options { |
|
34 | + $option = new class extends Options |
|
35 | + { |
|
35 | 36 | public int $customOption = 3; |
36 | 37 | }; |
37 | 38 | $option->customOption = 5; |
@@ -14,8 +14,8 @@ |
||
14 | 14 | { |
15 | 15 | public readonly string $name; |
16 | 16 | |
17 | - public function __construct(string|\BackedEnum $name) |
|
17 | + public function __construct(string | \BackedEnum $name) |
|
18 | 18 | { |
19 | - $this->name = \is_object($name) ? (string) $name->value : $name; |
|
19 | + $this->name = \is_object($name) ? (string)$name->value : $name; |
|
20 | 20 | } |
21 | 21 | } |
@@ -89,9 +89,12 @@ discard block |
||
89 | 89 | new ExceptionInterceptor(), |
90 | 90 | ], self::createMock(CoreInterface::class)); |
91 | 91 | |
92 | - try { |
|
92 | + try |
|
93 | + { |
|
93 | 94 | $pipeline->callAction('controller', 'action'); |
94 | - } catch (\RuntimeException) { |
|
95 | + } |
|
96 | + catch (\RuntimeException) |
|
97 | + { |
|
95 | 98 | // Attributes won't be lost after legacy interceptor |
96 | 99 | self::assertSame(['key' => 'value'], $state->context->getAttributes()); |
97 | 100 | } |
@@ -111,7 +114,8 @@ discard block |
||
111 | 114 | $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler); |
112 | 115 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
113 | 116 | |
114 | - foreach ($interceptors as $interceptor) { |
|
117 | + foreach ($interceptors as $interceptor) |
|
118 | + { |
|
115 | 119 | $pipeline->addInterceptor($interceptor); |
116 | 120 | } |
117 | 121 |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | new ExceptionInterceptor(), |
92 | 92 | ], self::createMock(CoreInterface::class)); |
93 | 93 | |
94 | - try { |
|
94 | + try{ |
|
95 | 95 | $pipeline->callAction('controller', 'action'); |
96 | - } catch (\RuntimeException) { |
|
96 | + }catch (\RuntimeException){ |
|
97 | 97 | // Attributes won't be lost after legacy interceptor |
98 | 98 | self::assertSame(['key' => 'value'], $state->context->getAttributes()); |
99 | 99 | } |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | */ |
125 | 125 | private function createPipeline( |
126 | 126 | array $interceptors = [], |
127 | - CoreInterface|HandlerInterface|null $lastHandler = null, |
|
128 | - EventDispatcherInterface|null $dispatcher = null, |
|
127 | + CoreInterface | HandlerInterface | null $lastHandler = null, |
|
128 | + EventDispatcherInterface | null $dispatcher = null, |
|
129 | 129 | ): InterceptorPipeline { |
130 | 130 | $pipeline = new InterceptorPipeline($dispatcher); |
131 | 131 | |
132 | 132 | $lastHandler instanceof CoreInterface and $pipeline = $pipeline->withCore($lastHandler); |
133 | 133 | $lastHandler instanceof HandlerInterface and $pipeline = $pipeline->withHandler($lastHandler); |
134 | 134 | |
135 | - foreach ($interceptors as $interceptor) { |
|
135 | + foreach ($interceptors as $interceptor){ |
|
136 | 136 | $pipeline->addInterceptor($interceptor); |
137 | 137 | } |
138 | 138 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
25 | 25 | { |
26 | - switch ($token->type) { |
|
26 | + switch ($token->type){ |
|
27 | 27 | case DynamicGrammar::TYPE_DIRECTIVE: |
28 | 28 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
29 | 29 | $asm->push($this->directive); |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | break; |
49 | 49 | |
50 | 50 | case DynamicGrammar::TYPE_KEYWORD: |
51 | - if ($this->directive !== null) { |
|
51 | + if ($this->directive !== null){ |
|
52 | 52 | $this->directive->name = $token->content; |
53 | 53 | } |
54 | 54 | break; |
55 | 55 | |
56 | 56 | case DynamicGrammar::TYPE_BODY: |
57 | - if ($this->directive !== null) { |
|
57 | + if ($this->directive !== null){ |
|
58 | 58 | $this->directive->body = $token->content; |
59 | 59 | $this->directive->values = $this->fetchValues($this->directive->body); |
60 | 60 | |
61 | 61 | $this->directive = null; |
62 | 62 | } |
63 | 63 | |
64 | - if ($this->output !== null) { |
|
64 | + if ($this->output !== null){ |
|
65 | 65 | $this->output->body = $token->content; |
66 | 66 | } |
67 | 67 | |
@@ -79,31 +79,31 @@ discard block |
||
79 | 79 | |
80 | 80 | $src = new StringStream($body); |
81 | 81 | |
82 | - while ($n = $src->peak()) { |
|
83 | - if (\in_array($n, ['"', "'"], true)) { |
|
82 | + while ($n = $src->peak()){ |
|
83 | + if (\in_array($n, ['"', "'"], true)){ |
|
84 | 84 | $values[\count($values) - 1] .= $n; |
85 | - while (($nn = $src->peak()) !== null) { |
|
85 | + while (($nn = $src->peak()) !== null){ |
|
86 | 86 | $values[\count($values) - 1] .= $nn; |
87 | - if ($nn === $n) { |
|
87 | + if ($nn === $n){ |
|
88 | 88 | break; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | - if ($n === ',' && $level === 0) { |
|
94 | + if ($n === ',' && $level === 0){ |
|
95 | 95 | $values[] = ''; |
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | 99 | $values[\count($values) - 1] .= $n; |
100 | 100 | |
101 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
101 | + if ($n === '(' || $n === '[' || $n === '{'){ |
|
102 | 102 | $level++; |
103 | 103 | continue; |
104 | 104 | } |
105 | 105 | |
106 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
106 | + if ($n === ')' || $n === ']' || $n === '}'){ |
|
107 | 107 | $level--; |
108 | 108 | } |
109 | 109 | } |
@@ -23,7 +23,8 @@ discard block |
||
23 | 23 | |
24 | 24 | public function handle(Parser $parser, Assembler $asm, Token $token): void |
25 | 25 | { |
26 | - switch ($token->type) { |
|
26 | + switch ($token->type) |
|
27 | + { |
|
27 | 28 | case DynamicGrammar::TYPE_DIRECTIVE: |
28 | 29 | $this->directive = new Directive(new Parser\Context($token, $parser->getPath())); |
29 | 30 | $asm->push($this->directive); |
@@ -48,20 +49,23 @@ discard block |
||
48 | 49 | break; |
49 | 50 | |
50 | 51 | case DynamicGrammar::TYPE_KEYWORD: |
51 | - if ($this->directive !== null) { |
|
52 | + if ($this->directive !== null) |
|
53 | + { |
|
52 | 54 | $this->directive->name = $token->content; |
53 | 55 | } |
54 | 56 | break; |
55 | 57 | |
56 | 58 | case DynamicGrammar::TYPE_BODY: |
57 | - if ($this->directive !== null) { |
|
59 | + if ($this->directive !== null) |
|
60 | + { |
|
58 | 61 | $this->directive->body = $token->content; |
59 | 62 | $this->directive->values = $this->fetchValues($this->directive->body); |
60 | 63 | |
61 | 64 | $this->directive = null; |
62 | 65 | } |
63 | 66 | |
64 | - if ($this->output !== null) { |
|
67 | + if ($this->output !== null) |
|
68 | + { |
|
65 | 69 | $this->output->body = $token->content; |
66 | 70 | } |
67 | 71 | |
@@ -79,31 +83,38 @@ discard block |
||
79 | 83 | |
80 | 84 | $src = new StringStream($body); |
81 | 85 | |
82 | - while ($n = $src->peak()) { |
|
83 | - if (\in_array($n, ['"', "'"], true)) { |
|
86 | + while ($n = $src->peak()) |
|
87 | + { |
|
88 | + if (\in_array($n, ['"', "'"], true)) |
|
89 | + { |
|
84 | 90 | $values[\count($values) - 1] .= $n; |
85 | - while (($nn = $src->peak()) !== null) { |
|
91 | + while (($nn = $src->peak()) !== null) |
|
92 | + { |
|
86 | 93 | $values[\count($values) - 1] .= $nn; |
87 | - if ($nn === $n) { |
|
94 | + if ($nn === $n) |
|
95 | + { |
|
88 | 96 | break; |
89 | 97 | } |
90 | 98 | } |
91 | 99 | continue; |
92 | 100 | } |
93 | 101 | |
94 | - if ($n === ',' && $level === 0) { |
|
102 | + if ($n === ',' && $level === 0) |
|
103 | + { |
|
95 | 104 | $values[] = ''; |
96 | 105 | continue; |
97 | 106 | } |
98 | 107 | |
99 | 108 | $values[\count($values) - 1] .= $n; |
100 | 109 | |
101 | - if ($n === '(' || $n === '[' || $n === '{') { |
|
110 | + if ($n === '(' || $n === '[' || $n === '{') |
|
111 | + { |
|
102 | 112 | $level++; |
103 | 113 | continue; |
104 | 114 | } |
105 | 115 | |
106 | - if ($n === ')' || $n === ']' || $n === '}') { |
|
116 | + if ($n === ')' || $n === ']' || $n === '}') |
|
117 | + { |
|
107 | 118 | $level--; |
108 | 119 | } |
109 | 120 | } |
@@ -21,8 +21,8 @@ |
||
21 | 21 | private readonly bool $isLegacy; |
22 | 22 | |
23 | 23 | public function __construct( |
24 | - private readonly CoreInterface|InterceptorHandler $core, |
|
25 | - ) { |
|
24 | + private readonly CoreInterface | InterceptorHandler $core, |
|
25 | + ){ |
|
26 | 26 | $this->isLegacy = !$core instanceof HandlerInterface; |
27 | 27 | } |
28 | 28 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ?string $comment = null, |
24 | 24 | ?string $namespace = null, |
25 | 25 | private readonly bool $isDomain = false, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | parent::__construct($config, $name, $comment, $namespace); |
28 | 28 | } |
29 | 29 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $this->class->addConstant('SINGLETONS', [])->setProtected(); |
44 | 44 | $this->class->addConstant('DEPENDENCIES', [])->setProtected(); |
45 | 45 | |
46 | - if ($this->isDomain) { |
|
46 | + if ($this->isDomain){ |
|
47 | 47 | $this->class->addConstant('INTERCEPTORS', [])->setProtected(); |
48 | 48 | $this->namespace->addUse(HandlerInterface::class); |
49 | 49 | $this->class->getConstant('SINGLETONS')->setValue([ |
@@ -43,7 +43,8 @@ |
||
43 | 43 | $this->class->addConstant('SINGLETONS', [])->setProtected(); |
44 | 44 | $this->class->addConstant('DEPENDENCIES', [])->setProtected(); |
45 | 45 | |
46 | - if ($this->isDomain) { |
|
46 | + if ($this->isDomain) |
|
47 | + { |
|
47 | 48 | $this->class->addConstant('INTERCEPTORS', [])->setProtected(); |
48 | 49 | $this->namespace->addUse(HandlerInterface::class); |
49 | 50 | $this->class->getConstant('SINGLETONS')->setValue([ |