@@ -85,7 +85,8 @@ discard block |
||
85 | 85 | ): Response { |
86 | 86 | /** @var CookieQueue $cookieQueue */ |
87 | 87 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
88 | - if ($cookieQueue === null) { |
|
88 | + if ($cookieQueue === null) |
|
89 | + { |
|
89 | 90 | return $response->withAddedHeader( |
90 | 91 | 'Set-Cookie', |
91 | 92 | Cookie::create( |
@@ -101,9 +102,12 @@ discard block |
||
101 | 102 | ); |
102 | 103 | } |
103 | 104 | |
104 | - if ($tokenID === null) { |
|
105 | + if ($tokenID === null) |
|
106 | + { |
|
105 | 107 | $cookieQueue->delete($this->cookie); |
106 | - } else { |
|
108 | + } |
|
109 | + else |
|
110 | + { |
|
107 | 111 | $cookieQueue->set( |
108 | 112 | $this->cookie, |
109 | 113 | $tokenID, |
@@ -134,7 +138,8 @@ discard block |
||
134 | 138 | */ |
135 | 139 | private function getLifetime(\DateTimeInterface $expiresAt = null): ?int |
136 | 140 | { |
137 | - if ($expiresAt === null) { |
|
141 | + if ($expiresAt === null) |
|
142 | + { |
|
138 | 143 | return null; |
139 | 144 | } |
140 | 145 |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | public function __construct(array $visitors = []) |
21 | 21 | { |
22 | - foreach ($visitors as $visitor) { |
|
22 | + foreach ($visitors as $visitor) |
|
23 | + { |
|
23 | 24 | $this->addVisitor($visitor); |
24 | 25 | } |
25 | 26 | } |
@@ -34,8 +35,10 @@ discard block |
||
34 | 35 | |
35 | 36 | public function removeVisitor(VisitorInterface $visitor): void |
36 | 37 | { |
37 | - foreach ($this->visitors as $index => $added) { |
|
38 | - if ($added === $visitor) { |
|
38 | + foreach ($this->visitors as $index => $added) |
|
39 | + { |
|
40 | + if ($added === $visitor) |
|
41 | + { |
|
39 | 42 | unset($this->visitors[$index]); |
40 | 43 | break; |
41 | 44 | } |
@@ -56,22 +59,27 @@ discard block |
||
56 | 59 | $context ??= new VisitorContext(); |
57 | 60 | |
58 | 61 | $ctx = clone $context; |
59 | - foreach ($nodes as $index => $node) { |
|
60 | - if ($this->stopTraversal) { |
|
62 | + foreach ($nodes as $index => $node) |
|
63 | + { |
|
64 | + if ($this->stopTraversal) |
|
65 | + { |
|
61 | 66 | break; |
62 | 67 | } |
63 | 68 | |
64 | 69 | $traverseChildren = true; |
65 | 70 | $breakVisitorID = null; |
66 | 71 | |
67 | - if ($node instanceof NodeInterface) { |
|
72 | + if ($node instanceof NodeInterface) |
|
73 | + { |
|
68 | 74 | $ctx = $context->withNode($node); |
69 | 75 | } |
70 | 76 | |
71 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
77 | + foreach ($this->visitors as $visitorID => $visitor) |
|
78 | + { |
|
72 | 79 | $result = $visitor->enterNode($node, $ctx); |
73 | 80 | |
74 | - switch (true) { |
|
81 | + switch (true) |
|
82 | + { |
|
75 | 83 | case $result === null: |
76 | 84 | break; |
77 | 85 | |
@@ -101,17 +109,21 @@ discard block |
||
101 | 109 | } |
102 | 110 | |
103 | 111 | // sub nodes |
104 | - if ($traverseChildren && $node instanceof NodeInterface) { |
|
112 | + if ($traverseChildren && $node instanceof NodeInterface) |
|
113 | + { |
|
105 | 114 | $nodes[$index] = $this->traverseNode($node, $ctx); |
106 | - if ($this->stopTraversal) { |
|
115 | + if ($this->stopTraversal) |
|
116 | + { |
|
107 | 117 | break; |
108 | 118 | } |
109 | 119 | } |
110 | 120 | |
111 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
121 | + foreach ($this->visitors as $visitorID => $visitor) |
|
122 | + { |
|
112 | 123 | $result = $visitor->leaveNode($node, $ctx); |
113 | 124 | |
114 | - switch (true) { |
|
125 | + switch (true) |
|
126 | + { |
|
115 | 127 | case $result === null: |
116 | 128 | break; |
117 | 129 | |
@@ -133,7 +145,8 @@ discard block |
||
133 | 145 | ); |
134 | 146 | } |
135 | 147 | |
136 | - if ($breakVisitorID === $visitorID) { |
|
148 | + if ($breakVisitorID === $visitorID) |
|
149 | + { |
|
137 | 150 | break; |
138 | 151 | } |
139 | 152 | } |
@@ -148,18 +161,22 @@ discard block |
||
148 | 161 | private function traverseNode(NodeInterface $node, VisitorContext $context): NodeInterface |
149 | 162 | { |
150 | 163 | $ctx = clone $context; |
151 | - foreach ($node as $name => $_) { |
|
164 | + foreach ($node as $name => $_) |
|
165 | + { |
|
152 | 166 | $_child = &$node->$name; |
153 | - if (\is_array($_child)) { |
|
167 | + if (\is_array($_child)) |
|
168 | + { |
|
154 | 169 | $_child = $this->traverse($_child, $ctx); |
155 | - if ($this->stopTraversal) { |
|
170 | + if ($this->stopTraversal) |
|
171 | + { |
|
156 | 172 | break; |
157 | 173 | } |
158 | 174 | |
159 | 175 | continue; |
160 | 176 | } |
161 | 177 | |
162 | - if (!$_child instanceof NodeInterface) { |
|
178 | + if (!$_child instanceof NodeInterface) |
|
179 | + { |
|
163 | 180 | continue; |
164 | 181 | } |
165 | 182 | |
@@ -168,9 +185,11 @@ discard block |
||
168 | 185 | $traverseChildren = true; |
169 | 186 | $breakVisitorID = null; |
170 | 187 | |
171 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
188 | + foreach ($this->visitors as $visitorID => $visitor) |
|
189 | + { |
|
172 | 190 | $result = $visitor->enterNode($_child, $ctx); |
173 | - switch (true) { |
|
191 | + switch (true) |
|
192 | + { |
|
174 | 193 | case $result === null: |
175 | 194 | break; |
176 | 195 | |
@@ -198,17 +217,21 @@ discard block |
||
198 | 217 | } |
199 | 218 | } |
200 | 219 | |
201 | - if ($traverseChildren) { |
|
220 | + if ($traverseChildren) |
|
221 | + { |
|
202 | 222 | $_child = $this->traverseNode($_child, $ctx); |
203 | - if ($this->stopTraversal) { |
|
223 | + if ($this->stopTraversal) |
|
224 | + { |
|
204 | 225 | break; |
205 | 226 | } |
206 | 227 | } |
207 | 228 | |
208 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
229 | + foreach ($this->visitors as $visitorID => $visitor) |
|
230 | + { |
|
209 | 231 | $result = $visitor->leaveNode($_child, $ctx); |
210 | 232 | |
211 | - switch (true) { |
|
233 | + switch (true) |
|
234 | + { |
|
212 | 235 | case $result === null: |
213 | 236 | break; |
214 | 237 | |
@@ -226,7 +249,8 @@ discard block |
||
226 | 249 | ); |
227 | 250 | } |
228 | 251 | |
229 | - if ($breakVisitorID === $visitorID) { |
|
252 | + if ($breakVisitorID === $visitorID) |
|
253 | + { |
|
230 | 254 | break; |
231 | 255 | } |
232 | 256 | } |
@@ -25,15 +25,21 @@ |
||
25 | 25 | |
26 | 26 | public function patch(array $config): array |
27 | 27 | { |
28 | - try { |
|
28 | + try |
|
29 | + { |
|
29 | 30 | $_target = &$this->dotGet($config, $this->position); |
30 | 31 | |
31 | - if ($this->key !== null) { |
|
32 | + if ($this->key !== null) |
|
33 | + { |
|
32 | 34 | $_target = \array_merge([$this->key => $this->value], $_target); |
33 | - } else { |
|
35 | + } |
|
36 | + else |
|
37 | + { |
|
34 | 38 | \array_unshift($_target, $this->value); |
35 | 39 | } |
36 | - } catch (DotNotFoundException $e) { |
|
40 | + } |
|
41 | + catch (DotNotFoundException $e) |
|
42 | + { |
|
37 | 43 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
38 | 44 | } |
39 | 45 |
@@ -24,10 +24,13 @@ |
||
24 | 24 | |
25 | 25 | public function patch(array $config): array |
26 | 26 | { |
27 | - try { |
|
27 | + try |
|
28 | + { |
|
28 | 29 | $_target = &$this->dotGet($config, $this->key); |
29 | 30 | $_target = $this->value; |
30 | - } catch (DotNotFoundException $e) { |
|
31 | + } |
|
32 | + catch (DotNotFoundException $e) |
|
33 | + { |
|
31 | 34 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
32 | 35 | } |
33 | 36 |
@@ -37,40 +37,55 @@ discard block |
||
37 | 37 | $setters = []; |
38 | 38 | $class = new \ReflectionClass($filter); |
39 | 39 | |
40 | - foreach ($class->getProperties() as $property) { |
|
40 | + foreach ($class->getProperties() as $property) |
|
41 | + { |
|
41 | 42 | /** @var object $attribute */ |
42 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
43 | - if ($attribute instanceof AbstractInput) { |
|
43 | + foreach ($this->reader->getPropertyMetadata($property) as $attribute) |
|
44 | + { |
|
45 | + if ($attribute instanceof AbstractInput) |
|
46 | + { |
|
44 | 47 | $this->setValue($filter, $property, $attribute->getValue($input, $property)); |
45 | 48 | $schema[$property->getName()] = $attribute->getSchema($property); |
46 | - } elseif ($attribute instanceof NestedFilter) { |
|
49 | + } |
|
50 | + elseif ($attribute instanceof NestedFilter) |
|
51 | + { |
|
47 | 52 | $prefix = $attribute->prefix ?? $property->name; |
48 | - try { |
|
53 | + try |
|
54 | + { |
|
49 | 55 | $value = $this->provider->createFilter( |
50 | 56 | $attribute->class, |
51 | 57 | $input->withPrefix($prefix) |
52 | 58 | ); |
53 | 59 | |
54 | 60 | $this->setValue($filter, $property, $value); |
55 | - } catch (ValidationException $e) { |
|
61 | + } |
|
62 | + catch (ValidationException $e) |
|
63 | + { |
|
56 | 64 | $errors[$prefix] = $e->errors; |
57 | 65 | } |
58 | 66 | |
59 | 67 | $schema[$property->getName()] = $attribute->getSchema($property); |
60 | - } elseif ($attribute instanceof NestedArray) { |
|
68 | + } |
|
69 | + elseif ($attribute instanceof NestedArray) |
|
70 | + { |
|
61 | 71 | $values = $attribute->getValue($input, $property); |
62 | 72 | $propertyValues = []; |
63 | 73 | |
64 | 74 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
65 | 75 | |
66 | - if (\is_array($values)) { |
|
67 | - foreach (\array_keys($values) as $key) { |
|
68 | - try { |
|
76 | + if (\is_array($values)) |
|
77 | + { |
|
78 | + foreach (\array_keys($values) as $key) |
|
79 | + { |
|
80 | + try |
|
81 | + { |
|
69 | 82 | $propertyValues[$key] = $this->provider->createFilter( |
70 | 83 | $attribute->class, |
71 | 84 | $input->withPrefix($prefix . '.' . $key) |
72 | 85 | ); |
73 | - } catch (ValidationException $e) { |
|
86 | + } |
|
87 | + catch (ValidationException $e) |
|
88 | + { |
|
74 | 89 | $errors[$property->getName()][$key] = $e->errors; |
75 | 90 | } |
76 | 91 | } |
@@ -78,7 +93,9 @@ discard block |
||
78 | 93 | |
79 | 94 | $this->setValue($filter, $property, $propertyValues); |
80 | 95 | $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
81 | - } elseif ($attribute instanceof Setter) { |
|
96 | + } |
|
97 | + elseif ($attribute instanceof Setter) |
|
98 | + { |
|
82 | 99 | $setters[$property->getName()][] = $attribute; |
83 | 100 | } |
84 | 101 | } |
@@ -89,13 +106,15 @@ discard block |
||
89 | 106 | |
90 | 107 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
91 | 108 | { |
92 | - if ($value === null) { |
|
109 | + if ($value === null) |
|
110 | + { |
|
93 | 111 | return; |
94 | 112 | } |
95 | 113 | |
96 | 114 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
97 | 115 | |
98 | - foreach ($setters as $setter) { |
|
116 | + foreach ($setters as $setter) |
|
117 | + { |
|
99 | 118 | $value = $setter->updateValue($value); |
100 | 119 | } |
101 | 120 |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __clone() |
18 | 18 | { |
19 | - foreach ($this->routes as $name => $route) { |
|
19 | + foreach ($this->routes as $name => $route) |
|
20 | + { |
|
20 | 21 | $this->routes[$name] = clone $route; |
21 | 22 | } |
22 | 23 | } |
@@ -92,7 +93,8 @@ discard block |
||
92 | 93 | */ |
93 | 94 | public function remove(string|array $name) |
94 | 95 | { |
95 | - foreach ((array) $name as $n) { |
|
96 | + foreach ((array) $name as $n) |
|
97 | + { |
|
96 | 98 | unset($this->routes[$n]); |
97 | 99 | } |
98 | 100 | } |
@@ -104,7 +106,8 @@ discard block |
||
104 | 106 | */ |
105 | 107 | public function addCollection(self $collection) |
106 | 108 | { |
107 | - foreach ($collection->all() as $name => $route) { |
|
109 | + foreach ($collection->all() as $name => $route) |
|
110 | + { |
|
108 | 111 | $this->routes[$name] = $route; |
109 | 112 | } |
110 | 113 | } |
@@ -120,7 +123,8 @@ discard block |
||
120 | 123 | */ |
121 | 124 | public function group(string $group) |
122 | 125 | { |
123 | - foreach ($this->routes as $route) { |
|
126 | + foreach ($this->routes as $route) |
|
127 | + { |
|
124 | 128 | $route->group($group); |
125 | 129 | } |
126 | 130 | } |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function getGroup(string $name): RouteGroup |
30 | 30 | { |
31 | - if (!isset($this->groups[$name])) { |
|
31 | + if (!isset($this->groups[$name])) |
|
32 | + { |
|
32 | 33 | $this->groups[$name] = $this->factory->make(RouteGroup::class); |
33 | 34 | } |
34 | 35 | |
@@ -60,7 +61,8 @@ discard block |
||
60 | 61 | */ |
61 | 62 | public function registerRoutes(RouterInterface $router): void |
62 | 63 | { |
63 | - foreach ($this->groups as $group) { |
|
64 | + foreach ($this->groups as $group) |
|
65 | + { |
|
64 | 66 | $group->register($router, $this->factory); |
65 | 67 | } |
66 | 68 | } |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | $targets = \iterator_to_array($this->parseAttributes($listener)); |
26 | 26 | |
27 | 27 | // If there are no targets, then listener can't be cached. |
28 | - if ($targets === []) { |
|
28 | + if ($targets === []) |
|
29 | + { |
|
29 | 30 | return false; |
30 | 31 | } |
31 | 32 | |
@@ -34,11 +35,13 @@ discard block |
||
34 | 35 | // We decided to load classes for each target separately. |
35 | 36 | // It allows us to cache classes for each target separately and if we reuse the |
36 | 37 | // same target in multiple listeners, we will not have to load classes for the same target. |
37 | - foreach ($targets as $target) { |
|
38 | + foreach ($targets as $target) |
|
39 | + { |
|
38 | 40 | $cacheKey = (string)$target; |
39 | 41 | |
40 | 42 | $classes = $this->readCache ? $this->memory->loadData($cacheKey) : null; |
41 | - if ($classes === null) { |
|
43 | + if ($classes === null) |
|
44 | + { |
|
42 | 45 | $this->memory->saveData( |
43 | 46 | $cacheKey, |
44 | 47 | $classes = $this->locator->getClasses($target), |