@@ -61,7 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | public function testMiddlewareProcessingEventShouldBeDispatched(): void |
63 | 63 | { |
64 | - $middleware = new class implements MiddlewareInterface { |
|
64 | + $middleware = new class implements MiddlewareInterface |
|
65 | + { |
|
65 | 66 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
66 | 67 | { |
67 | 68 | return (new ResponseFactory(new HttpConfig(['headers' => []])))->createResponse(200); |
@@ -90,7 +91,8 @@ discard block |
||
90 | 91 | $this->container->getBinder('http') |
91 | 92 | ->bind(ServerRequestInterface::class, static fn(CurrentRequest $cr) => $cr->get()); |
92 | 93 | |
93 | - $middleware = new class implements MiddlewareInterface { |
|
94 | + $middleware = new class implements MiddlewareInterface |
|
95 | + { |
|
94 | 96 | public function process( |
95 | 97 | ServerRequestInterface $request, |
96 | 98 | RequestHandlerInterface $handler, |
@@ -108,7 +110,8 @@ discard block |
||
108 | 110 | |
109 | 111 | $this->container->runScope( |
110 | 112 | new Scope(name: 'http'), |
111 | - function (ScopeInterface $c) use ($middleware) { |
|
113 | + function (ScopeInterface $c) use ($middleware) |
|
114 | + { |
|
112 | 115 | $request = new ServerRequest('GET', ''); |
113 | 116 | $handler = new CallableHandler(fn() => 'response', new ResponseFactory(new HttpConfig(['headers' => []]))); |
114 | 117 |
@@ -47,15 +47,15 @@ |
||
47 | 47 | |
48 | 48 | $declaration |
49 | 49 | ->addConstant('PRIVATE', 123) |
50 | - ->setVisibility(Visibility::PRIVATE); |
|
50 | + ->setVisibility(Visibility::private); |
|
51 | 51 | |
52 | 52 | $declaration |
53 | 53 | ->addConstant('PROTECTED', 456) |
54 | - ->setVisibility(Visibility::PROTECTED); |
|
54 | + ->setVisibility(Visibility::protected); |
|
55 | 55 | |
56 | 56 | $declaration |
57 | 57 | ->addConstant('PUBLIC', 789) |
58 | - ->setVisibility(Visibility::PUBLIC); |
|
58 | + ->setVisibility(Visibility::public); |
|
59 | 59 | |
60 | 60 | $declaration |
61 | 61 | ->addConstant('WITH_COMMENT', 'foo') |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | use AttributeAware; |
22 | 22 | use NameAware; |
23 | 23 | |
24 | - protected NettePromotedParameter|NetteParameter $element; |
|
24 | + protected NettePromotedParameter | NetteParameter $element; |
|
25 | 25 | |
26 | 26 | public function __construct(string $name) |
27 | 27 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $type = $this->element->getType(false); |
53 | 53 | |
54 | - return $type === null ? null : (string) $type; |
|
54 | + return $type === null ? null : (string)$type; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public function setNullable(bool $state = true): static |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | /** |
87 | 87 | * @internal |
88 | 88 | */ |
89 | - public static function fromElement(NetteParameter|NettePromotedParameter $element): static |
|
89 | + public static function fromElement(NetteParameter | NettePromotedParameter $element): static |
|
90 | 90 | { |
91 | 91 | $parameter = new static($element->getName()); |
92 | 92 |
@@ -58,19 +58,19 @@ |
||
58 | 58 | */ |
59 | 59 | protected function mapDirectories(array $directories): array |
60 | 60 | { |
61 | - if (!isset($directories['root'])) { |
|
61 | + if (!isset($directories['root'])){ |
|
62 | 62 | throw new BootException('Missing required directory `root`.'); |
63 | 63 | } |
64 | 64 | |
65 | - if (!isset($directories['app'])) { |
|
66 | - $directories['app'] = $directories['root'] . '/'; |
|
65 | + if (!isset($directories['app'])){ |
|
66 | + $directories['app'] = $directories['root'].'/'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return array_merge([ |
70 | - 'vendor' => $directories['root'] . '/vendor/', |
|
71 | - 'runtime' => $directories['root'] . '/runtime/', |
|
72 | - 'config' => $directories['app'] . '/config/', |
|
73 | - 'resources' => $directories['root'] . '/resources/', |
|
70 | + 'vendor' => $directories['root'].'/vendor/', |
|
71 | + 'runtime' => $directories['root'].'/runtime/', |
|
72 | + 'config' => $directories['app'].'/config/', |
|
73 | + 'resources' => $directories['root'].'/resources/', |
|
74 | 74 | ], $directories); |
75 | 75 | } |
76 | 76 | } |
@@ -58,11 +58,13 @@ |
||
58 | 58 | */ |
59 | 59 | protected function mapDirectories(array $directories): array |
60 | 60 | { |
61 | - if (!isset($directories['root'])) { |
|
61 | + if (!isset($directories['root'])) |
|
62 | + { |
|
62 | 63 | throw new BootException('Missing required directory `root`.'); |
63 | 64 | } |
64 | 65 | |
65 | - if (!isset($directories['app'])) { |
|
66 | + if (!isset($directories['app'])) |
|
67 | + { |
|
66 | 68 | $directories['app'] = $directories['root'] . '/'; |
67 | 69 | } |
68 | 70 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function __construct( |
43 | 43 | private readonly ConfiguratorInterface $config, |
44 | 44 | private readonly KernelInterface $kernel, |
45 | - ) { |
|
45 | + ){ |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function init(ConsoleBootloader $console, DirectoriesInterface $dir): void |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $console->addCommand(MiddlewareCommand::class); |
57 | 57 | $console->addCommand(FilterCommand::class); |
58 | 58 | |
59 | - try { |
|
59 | + try{ |
|
60 | 60 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
61 | - } catch (ReflectionException) { |
|
61 | + }catch (ReflectionException){ |
|
62 | 62 | $defaultNamespace = ''; |
63 | 63 | } |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * Base directory for generated classes, class will be automatically localed into sub directory |
74 | 74 | * using given namespace. |
75 | 75 | */ |
76 | - 'directory' => $dir->get('app') . 'src/', |
|
76 | + 'directory' => $dir->get('app').'src/', |
|
77 | 77 | |
78 | 78 | /* |
79 | 79 | * Default namespace to be applied for every generated class. By default uses Kernel namespace |
@@ -56,9 +56,12 @@ |
||
56 | 56 | $console->addCommand(MiddlewareCommand::class); |
57 | 57 | $console->addCommand(FilterCommand::class); |
58 | 58 | |
59 | - try { |
|
59 | + try |
|
60 | + { |
|
60 | 61 | $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName(); |
61 | - } catch (ReflectionException) { |
|
62 | + } |
|
63 | + catch (ReflectionException) |
|
64 | + { |
|
62 | 65 | $defaultNamespace = ''; |
63 | 66 | } |
64 | 67 |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $handler = new ConsoleRenderer(); |
120 | 120 | $handler->setColorsSupport(true); |
121 | 121 | |
122 | - try { |
|
122 | + try{ |
|
123 | 123 | $this->makeException(); |
124 | - } catch (\Throwable $e) { |
|
124 | + }catch (\Throwable $e){ |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $handler = new PlainRenderer(); |
136 | 136 | |
137 | - try { |
|
137 | + try{ |
|
138 | 138 | $this->makeException(); |
139 | - } catch (\Throwable $e) { |
|
139 | + }catch (\Throwable $e){ |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | { |
150 | 150 | $handler = new JsonRenderer(); |
151 | 151 | |
152 | - try { |
|
152 | + try{ |
|
153 | 153 | $this->makeException(); |
154 | - } catch (\Throwable $e) { |
|
154 | + }catch (\Throwable $e){ |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | |
163 | 163 | public function makeException(): void |
164 | 164 | { |
165 | - try { |
|
165 | + try{ |
|
166 | 166 | $f = function (): void { |
167 | 167 | throw new \RuntimeException('error'); |
168 | 168 | }; |
169 | 169 | |
170 | 170 | $f(); |
171 | - } catch (\Throwable $e) { |
|
171 | + }catch (\Throwable $e){ |
|
172 | 172 | throw new \LogicException('error', 0, $e); |
173 | 173 | } |
174 | 174 | } |
@@ -119,9 +119,12 @@ discard block |
||
119 | 119 | $handler = new ConsoleRenderer(); |
120 | 120 | $handler->setColorsSupport(true); |
121 | 121 | |
122 | - try { |
|
122 | + try |
|
123 | + { |
|
123 | 124 | $this->makeException(); |
124 | - } catch (\Throwable $e) { |
|
125 | + } |
|
126 | + catch (\Throwable $e) |
|
127 | + { |
|
125 | 128 | } |
126 | 129 | |
127 | 130 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -134,9 +137,12 @@ discard block |
||
134 | 137 | { |
135 | 138 | $handler = new PlainRenderer(); |
136 | 139 | |
137 | - try { |
|
140 | + try |
|
141 | + { |
|
138 | 142 | $this->makeException(); |
139 | - } catch (\Throwable $e) { |
|
143 | + } |
|
144 | + catch (\Throwable $e) |
|
145 | + { |
|
140 | 146 | } |
141 | 147 | |
142 | 148 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -149,9 +155,12 @@ discard block |
||
149 | 155 | { |
150 | 156 | $handler = new JsonRenderer(); |
151 | 157 | |
152 | - try { |
|
158 | + try |
|
159 | + { |
|
153 | 160 | $this->makeException(); |
154 | - } catch (\Throwable $e) { |
|
161 | + } |
|
162 | + catch (\Throwable $e) |
|
163 | + { |
|
155 | 164 | } |
156 | 165 | |
157 | 166 | $result = $handler->render($e, Verbosity::DEBUG); |
@@ -162,13 +171,16 @@ discard block |
||
162 | 171 | |
163 | 172 | public function makeException(): void |
164 | 173 | { |
165 | - try { |
|
174 | + try |
|
175 | + { |
|
166 | 176 | $f = function (): void { |
167 | 177 | throw new \RuntimeException('error'); |
168 | 178 | }; |
169 | 179 | |
170 | 180 | $f(); |
171 | - } catch (\Throwable $e) { |
|
181 | + } |
|
182 | + catch (\Throwable $e) |
|
183 | + { |
|
172 | 184 | throw new \LogicException('error', 0, $e); |
173 | 185 | } |
174 | 186 | } |
@@ -21,19 +21,19 @@ |
||
21 | 21 | */ |
22 | 22 | public function leaveNode(Node $node): void |
23 | 23 | { |
24 | - if ($node instanceof ClassMethod && $node->name->name === '__construct') { |
|
25 | - foreach ($node->params as $param) { |
|
26 | - if ($param->type instanceof NullableType) { |
|
27 | - if ($param->type->type instanceof Identifier) { |
|
24 | + if ($node instanceof ClassMethod && $node->name->name === '__construct'){ |
|
25 | + foreach ($node->params as $param){ |
|
26 | + if ($param->type instanceof NullableType){ |
|
27 | + if ($param->type->type instanceof Identifier){ |
|
28 | 28 | $type = $param->type->type->name; |
29 | - } else { |
|
29 | + }else{ |
|
30 | 30 | $type = implode('\\', $param->type->type->parts); |
31 | 31 | } |
32 | 32 | |
33 | 33 | $type = "?$type"; |
34 | - } elseif ($param->type instanceof Name) { |
|
34 | + } elseif ($param->type instanceof Name){ |
|
35 | 35 | $type = implode('\\', $param->type->parts); |
36 | - } else { |
|
36 | + }else{ |
|
37 | 37 | $type = $param->type->name ?? null; |
38 | 38 | } |
39 | 39 |
@@ -21,19 +21,29 @@ |
||
21 | 21 | */ |
22 | 22 | public function leaveNode(Node $node): void |
23 | 23 | { |
24 | - if ($node instanceof ClassMethod && $node->name->name === '__construct') { |
|
25 | - foreach ($node->params as $param) { |
|
26 | - if ($param->type instanceof NullableType) { |
|
27 | - if ($param->type->type instanceof Identifier) { |
|
24 | + if ($node instanceof ClassMethod && $node->name->name === '__construct') |
|
25 | + { |
|
26 | + foreach ($node->params as $param) |
|
27 | + { |
|
28 | + if ($param->type instanceof NullableType) |
|
29 | + { |
|
30 | + if ($param->type->type instanceof Identifier) |
|
31 | + { |
|
28 | 32 | $type = $param->type->type->name; |
29 | - } else { |
|
33 | + } |
|
34 | + else |
|
35 | + { |
|
30 | 36 | $type = implode('\\', $param->type->type->parts); |
31 | 37 | } |
32 | 38 | |
33 | 39 | $type = "?$type"; |
34 | - } elseif ($param->type instanceof Name) { |
|
40 | + } |
|
41 | + elseif ($param->type instanceof Name) |
|
42 | + { |
|
35 | 43 | $type = implode('\\', $param->type->parts); |
36 | - } else { |
|
44 | + } |
|
45 | + else |
|
46 | + { |
|
37 | 47 | $type = $param->type->name ?? null; |
38 | 48 | } |
39 | 49 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | $i = new Injector(); |
25 | 25 | |
26 | - $filename = __DIR__ . '/Fixtures/TestClass.php'; |
|
26 | + $filename = __DIR__.'/Fixtures/TestClass.php'; |
|
27 | 27 | $r = $i->injectDependencies( |
28 | 28 | file_get_contents($filename), |
29 | 29 | $this->getDefinition( |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | ) |
37 | 37 | ); |
38 | 38 | |
39 | - $this->assertStringContainsString(Some::class . ';', $r); |
|
40 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as Some2;', $r); |
|
41 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); |
|
42 | - $this->assertStringContainsString(ATest3::class . ';', $r); |
|
39 | + $this->assertStringContainsString(Some::class.';', $r); |
|
40 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as Some2;', $r); |
|
41 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); |
|
42 | + $this->assertStringContainsString(ATest3::class.';', $r); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | { |
50 | 50 | $i = new Injector(); |
51 | 51 | |
52 | - $filename = __DIR__ . '/Fixtures/TestClassWithImports.php'; |
|
52 | + $filename = __DIR__.'/Fixtures/TestClassWithImports.php'; |
|
53 | 53 | $r = $i->injectDependencies( |
54 | 54 | file_get_contents($filename), |
55 | 55 | $this->getDefinition( |
@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | ) |
63 | 63 | ); |
64 | 64 | |
65 | - $this->assertStringContainsString(Some::class . ' as FTest;', $r); |
|
66 | - $this->assertStringNotContainsString(Some::class . ';', $r); |
|
67 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as TestAlias;', $r); |
|
68 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); |
|
69 | - $this->assertStringContainsString(ATest3::class . ' as ATest;', $r); |
|
70 | - $this->assertStringNotContainsString(ATest3::class . ';', $r); |
|
65 | + $this->assertStringContainsString(Some::class.' as FTest;', $r); |
|
66 | + $this->assertStringNotContainsString(Some::class.';', $r); |
|
67 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as TestAlias;', $r); |
|
68 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); |
|
69 | + $this->assertStringContainsString(ATest3::class.' as ATest;', $r); |
|
70 | + $this->assertStringNotContainsString(ATest3::class.';', $r); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $i = new Injector(); |
79 | 79 | |
80 | - $filename = __DIR__ . '/Fixtures/ChildClass.php'; |
|
80 | + $filename = __DIR__.'/Fixtures/ChildClass.php'; |
|
81 | 81 | $r = $i->injectDependencies( |
82 | 82 | file_get_contents($filename), |
83 | 83 | $this->getDefinition( |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | ) |
91 | 91 | ); |
92 | 92 | |
93 | - $this->assertStringContainsString(Some::class . ';', $r); |
|
94 | - $this->assertStringContainsString(Fixtures\SubFolder\Some::class . ' as Some2;', $r); |
|
95 | - $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class . ';', $r); |
|
96 | - $this->assertStringContainsString(ATest3::class . ' as ATestAlias;', $r); |
|
97 | - $this->assertStringNotContainsString(ATest3::class . ';', $r); |
|
93 | + $this->assertStringContainsString(Some::class.';', $r); |
|
94 | + $this->assertStringContainsString(Fixtures\SubFolder\Some::class.' as Some2;', $r); |
|
95 | + $this->assertStringNotContainsString(Fixtures\SubFolder\Some::class.';', $r); |
|
96 | + $this->assertStringContainsString(ATest3::class.' as ATestAlias;', $r); |
|
97 | + $this->assertStringNotContainsString(ATest3::class.';', $r); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | public function testDuplicateProperty(): void |
101 | 101 | { |
102 | 102 | $i = new Injector(); |
103 | 103 | |
104 | - $filename = __DIR__ . '/Fixtures/DuplicatePropertyClass.php'; |
|
104 | + $filename = __DIR__.'/Fixtures/DuplicatePropertyClass.php'; |
|
105 | 105 | $r = $i->injectDependencies( |
106 | 106 | file_get_contents($filename), |
107 | 107 | $this->getDefinition( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | |
115 | - $this->assertStringContainsString(Some::class . ';', $r); |
|
115 | + $this->assertStringContainsString(Some::class.';', $r); |
|
116 | 116 | $this->assertStringContainsString('__construct(private readonly Some $test)', $r); |
117 | 117 | } |
118 | 118 |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | { |
21 | 21 | $cd = ClassNode::create('class\name'); |
22 | 22 | |
23 | - foreach ($stmts as $alias => $name) { |
|
23 | + foreach ($stmts as $alias => $name){ |
|
24 | 24 | $cd->addImportUsage($name, $alias); |
25 | 25 | } |
26 | 26 | |
27 | - foreach (Params::getParams('paramsSource') as $param) { |
|
27 | + foreach (Params::getParams('paramsSource') as $param){ |
|
28 | 28 | $cd->addParam($param); |
29 | 29 | } |
30 | 30 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $this->namespaces()->resolve($cd); |
33 | 33 | |
34 | 34 | $resolved = []; |
35 | - foreach ($cd->dependencies as $dependency) { |
|
35 | + foreach ($cd->dependencies as $dependency){ |
|
36 | 36 | $resolved[$dependency->property] = $dependency->type->getAliasOrShortName(); |
37 | 37 | } |
38 | 38 |
@@ -20,11 +20,13 @@ discard block |
||
20 | 20 | { |
21 | 21 | $cd = ClassNode::create('class\name'); |
22 | 22 | |
23 | - foreach ($stmts as $alias => $name) { |
|
23 | + foreach ($stmts as $alias => $name) |
|
24 | + { |
|
24 | 25 | $cd->addImportUsage($name, $alias); |
25 | 26 | } |
26 | 27 | |
27 | - foreach (Params::getParams('paramsSource') as $param) { |
|
28 | + foreach (Params::getParams('paramsSource') as $param) |
|
29 | + { |
|
28 | 30 | $cd->addParam($param); |
29 | 31 | } |
30 | 32 | |
@@ -32,7 +34,8 @@ discard block |
||
32 | 34 | $this->namespaces()->resolve($cd); |
33 | 35 | |
34 | 36 | $resolved = []; |
35 | - foreach ($cd->dependencies as $dependency) { |
|
37 | + foreach ($cd->dependencies as $dependency) |
|
38 | + { |
|
36 | 39 | $resolved[$dependency->property] = $dependency->type->getAliasOrShortName(); |
37 | 40 | } |
38 | 41 |