@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | private readonly bool $secure = false, |
| 23 | 23 | private readonly bool $httpOnly = true, |
| 24 | 24 | private readonly ?string $sameSite = null |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function fetchToken(Request $request): ?string |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | ): Response { |
| 40 | 40 | /** @var CookieQueue $cookieQueue */ |
| 41 | 41 | $cookieQueue = $request->getAttribute(CookieQueue::ATTRIBUTE); |
| 42 | - if ($cookieQueue === null) { |
|
| 42 | + if ($cookieQueue === null){ |
|
| 43 | 43 | return $response->withAddedHeader( |
| 44 | 44 | 'Set-Cookie', |
| 45 | 45 | Cookie::create( |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ($tokenID === null) { |
|
| 58 | + if ($tokenID === null){ |
|
| 59 | 59 | $cookieQueue->delete($this->cookie); |
| 60 | - } else { |
|
| 60 | + }else{ |
|
| 61 | 61 | $cookieQueue->set( |
| 62 | 62 | $this->cookie, |
| 63 | 63 | $tokenID, |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private function getLifetime(\DateTimeInterface $expiresAt = null): ?int |
| 86 | 86 | { |
| 87 | - if ($expiresAt === null) { |
|
| 87 | + if ($expiresAt === null){ |
|
| 88 | 88 | return null; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** @param TNode[] $nodes */ |
| 18 | 18 | public function __construct( |
| 19 | 19 | public array $nodes |
| 20 | - ) { |
|
| 20 | + ){ |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function getIterator(): \Generator |
@@ -19,7 +19,7 @@ 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 | $this->addVisitor($visitor); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | public function removeVisitor(VisitorInterface $visitor): void |
| 36 | 36 | { |
| 37 | - foreach ($this->visitors as $index => $added) { |
|
| 38 | - if ($added === $visitor) { |
|
| 37 | + foreach ($this->visitors as $index => $added){ |
|
| 38 | + if ($added === $visitor){ |
|
| 39 | 39 | unset($this->visitors[$index]); |
| 40 | 40 | break; |
| 41 | 41 | } |
@@ -56,22 +56,22 @@ discard block |
||
| 56 | 56 | $context ??= new VisitorContext(); |
| 57 | 57 | |
| 58 | 58 | $ctx = clone $context; |
| 59 | - foreach ($nodes as $index => $node) { |
|
| 60 | - if ($this->stopTraversal) { |
|
| 59 | + foreach ($nodes as $index => $node){ |
|
| 60 | + if ($this->stopTraversal){ |
|
| 61 | 61 | break; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | $traverseChildren = true; |
| 65 | 65 | $breakVisitorID = null; |
| 66 | 66 | |
| 67 | - if ($node instanceof NodeInterface) { |
|
| 67 | + if ($node instanceof NodeInterface){ |
|
| 68 | 68 | $ctx = $context->withNode($node); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
| 71 | + foreach ($this->visitors as $visitorID => $visitor){ |
|
| 72 | 72 | $result = $visitor->enterNode($node, $ctx); |
| 73 | 73 | |
| 74 | - switch (true) { |
|
| 74 | + switch (true){ |
|
| 75 | 75 | case $result === null: |
| 76 | 76 | break; |
| 77 | 77 | |
@@ -95,23 +95,23 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | default: |
| 97 | 97 | throw new \LogicException( |
| 98 | - 'enterNode() returned invalid value of type ' . \gettype($result) |
|
| 98 | + 'enterNode() returned invalid value of type '.\gettype($result) |
|
| 99 | 99 | ); |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // sub nodes |
| 104 | - if ($traverseChildren && $node instanceof NodeInterface) { |
|
| 104 | + if ($traverseChildren && $node instanceof NodeInterface){ |
|
| 105 | 105 | $nodes[$index] = $this->traverseNode($node, $ctx); |
| 106 | - if ($this->stopTraversal) { |
|
| 106 | + if ($this->stopTraversal){ |
|
| 107 | 107 | break; |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
| 111 | + foreach ($this->visitors as $visitorID => $visitor){ |
|
| 112 | 112 | $result = $visitor->leaveNode($node, $ctx); |
| 113 | 113 | |
| 114 | - switch (true) { |
|
| 114 | + switch (true){ |
|
| 115 | 115 | case $result === null: |
| 116 | 116 | break; |
| 117 | 117 | |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | default: |
| 131 | 131 | throw new \LogicException( |
| 132 | - 'leaveNode() returned invalid value of type ' . gettype($result) |
|
| 132 | + 'leaveNode() returned invalid value of type '.gettype($result) |
|
| 133 | 133 | ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ($breakVisitorID === $visitorID) { |
|
| 136 | + if ($breakVisitorID === $visitorID){ |
|
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -148,18 +148,18 @@ discard block |
||
| 148 | 148 | private function traverseNode(NodeInterface $node, VisitorContext $context): NodeInterface |
| 149 | 149 | { |
| 150 | 150 | $ctx = clone $context; |
| 151 | - foreach ($node as $name => $_) { |
|
| 151 | + foreach ($node as $name => $_){ |
|
| 152 | 152 | $_child = &$node->$name; |
| 153 | - if (\is_array($_child)) { |
|
| 153 | + if (\is_array($_child)){ |
|
| 154 | 154 | $_child = $this->traverse($_child, $ctx); |
| 155 | - if ($this->stopTraversal) { |
|
| 155 | + if ($this->stopTraversal){ |
|
| 156 | 156 | break; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | continue; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if (!$_child instanceof NodeInterface) { |
|
| 162 | + if (!$_child instanceof NodeInterface){ |
|
| 163 | 163 | continue; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | $traverseChildren = true; |
| 169 | 169 | $breakVisitorID = null; |
| 170 | 170 | |
| 171 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
| 171 | + foreach ($this->visitors as $visitorID => $visitor){ |
|
| 172 | 172 | $result = $visitor->enterNode($_child, $ctx); |
| 173 | - switch (true) { |
|
| 173 | + switch (true){ |
|
| 174 | 174 | case $result === null: |
| 175 | 175 | break; |
| 176 | 176 | |
@@ -193,22 +193,22 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | default: |
| 195 | 195 | throw new \LogicException( |
| 196 | - 'enterNode() returned invalid value of type ' . \gettype($result) |
|
| 196 | + 'enterNode() returned invalid value of type '.\gettype($result) |
|
| 197 | 197 | ); |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ($traverseChildren) { |
|
| 201 | + if ($traverseChildren){ |
|
| 202 | 202 | $_child = $this->traverseNode($_child, $ctx); |
| 203 | - if ($this->stopTraversal) { |
|
| 203 | + if ($this->stopTraversal){ |
|
| 204 | 204 | break; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - foreach ($this->visitors as $visitorID => $visitor) { |
|
| 208 | + foreach ($this->visitors as $visitorID => $visitor){ |
|
| 209 | 209 | $result = $visitor->leaveNode($_child, $ctx); |
| 210 | 210 | |
| 211 | - switch (true) { |
|
| 211 | + switch (true){ |
|
| 212 | 212 | case $result === null: |
| 213 | 213 | break; |
| 214 | 214 | |
@@ -222,11 +222,11 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | default: |
| 224 | 224 | throw new \LogicException( |
| 225 | - 'leaveNode() returned invalid value of type ' . \gettype($result) |
|
| 225 | + 'leaveNode() returned invalid value of type '.\gettype($result) |
|
| 226 | 226 | ); |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ($breakVisitorID === $visitorID) { |
|
| 229 | + if ($breakVisitorID === $visitorID){ |
|
| 230 | 230 | break; |
| 231 | 231 | } |
| 232 | 232 | } |
@@ -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 | } |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | string $position, |
| 20 | 20 | private readonly ?string $key, |
| 21 | 21 | private mixed $value |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | $this->position = $position === '.' ? '' : $position; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public function patch(array $config): array |
| 27 | 27 | { |
| 28 | - try { |
|
| 28 | + try{ |
|
| 29 | 29 | $_target = &$this->dotGet($config, $this->position); |
| 30 | 30 | |
| 31 | - if ($this->key !== null) { |
|
| 31 | + if ($this->key !== null){ |
|
| 32 | 32 | $_target = \array_merge([$this->key => $this->value], $_target); |
| 33 | - } else { |
|
| 33 | + }else{ |
|
| 34 | 34 | \array_unshift($_target, $this->value); |
| 35 | 35 | } |
| 36 | - } catch (DotNotFoundException $e) { |
|
| 36 | + }catch (DotNotFoundException $e){ |
|
| 37 | 37 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -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 | |
@@ -19,15 +19,15 @@ |
||
| 19 | 19 | public function __construct( |
| 20 | 20 | private string $key, |
| 21 | 21 | private mixed $value |
| 22 | - ) { |
|
| 22 | + ){ |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function patch(array $config): array |
| 26 | 26 | { |
| 27 | - try { |
|
| 27 | + try{ |
|
| 28 | 28 | $_target = &$this->dotGet($config, $this->key); |
| 29 | 29 | $_target = $this->value; |
| 30 | - } catch (DotNotFoundException $e) { |
|
| 30 | + }catch (DotNotFoundException $e){ |
|
| 31 | 31 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public function __construct( |
| 23 | 23 | private readonly FilterProviderInterface $provider, |
| 24 | 24 | private readonly ReaderInterface $reader |
| 25 | - ) { |
|
| 25 | + ){ |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -37,48 +37,48 @@ 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 | /** @var object $attribute */ |
| 42 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
| 43 | - if ($attribute instanceof AbstractInput) { |
|
| 42 | + foreach ($this->reader->getPropertyMetadata($property) as $attribute){ |
|
| 43 | + if ($attribute instanceof AbstractInput){ |
|
| 44 | 44 | $this->setValue($filter, $property, $attribute->getValue($input, $property)); |
| 45 | 45 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 46 | - } elseif ($attribute instanceof NestedFilter) { |
|
| 46 | + } elseif ($attribute instanceof NestedFilter){ |
|
| 47 | 47 | $prefix = $attribute->prefix ?? $property->name; |
| 48 | - try { |
|
| 48 | + try{ |
|
| 49 | 49 | $value = $this->provider->createFilter( |
| 50 | 50 | $attribute->class, |
| 51 | 51 | $input->withPrefix($prefix) |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | 54 | $this->setValue($filter, $property, $value); |
| 55 | - } catch (ValidationException $e) { |
|
| 55 | + }catch (ValidationException $e){ |
|
| 56 | 56 | $errors[$prefix] = $e->errors; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 60 | - } elseif ($attribute instanceof NestedArray) { |
|
| 60 | + } elseif ($attribute instanceof NestedArray){ |
|
| 61 | 61 | $values = $attribute->getValue($input, $property); |
| 62 | 62 | $propertyValues = []; |
| 63 | 63 | |
| 64 | 64 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
| 65 | 65 | |
| 66 | - if (\is_array($values)) { |
|
| 67 | - foreach (\array_keys($values) as $key) { |
|
| 68 | - try { |
|
| 66 | + if (\is_array($values)){ |
|
| 67 | + foreach (\array_keys($values) as $key){ |
|
| 68 | + try{ |
|
| 69 | 69 | $propertyValues[$key] = $this->provider->createFilter( |
| 70 | 70 | $attribute->class, |
| 71 | - $input->withPrefix($prefix . '.' . $key) |
|
| 71 | + $input->withPrefix($prefix.'.'.$key) |
|
| 72 | 72 | ); |
| 73 | - } catch (ValidationException $e) { |
|
| 73 | + }catch (ValidationException $e){ |
|
| 74 | 74 | $errors[$property->getName()][$key] = $e->errors; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | $this->setValue($filter, $property, $propertyValues); |
| 80 | - $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
|
| 81 | - } elseif ($attribute instanceof Setter) { |
|
| 80 | + $schema[$property->getName()] = [$attribute->class, $prefix.'.*']; |
|
| 81 | + } elseif ($attribute instanceof Setter){ |
|
| 82 | 82 | $setters[$property->getName()][] = $attribute; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
| 91 | 91 | { |
| 92 | - if ($value === null) { |
|
| 92 | + if ($value === null){ |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
| 97 | 97 | |
| 98 | - foreach ($setters as $setter) { |
|
| 98 | + foreach ($setters as $setter){ |
|
| 99 | 99 | $value = $setter->updateValue($value); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -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,7 @@ 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 | $this->routes[$name] = clone $route; |
| 21 | 21 | } |
| 22 | 22 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * TODO add return type |
| 92 | 92 | */ |
| 93 | - public function remove(string|array $name) |
|
| 93 | + public function remove(string | array $name) |
|
| 94 | 94 | { |
| 95 | - foreach ((array) $name as $n) { |
|
| 95 | + foreach ((array)$name as $n){ |
|
| 96 | 96 | unset($this->routes[$n]); |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function addCollection(self $collection) |
| 106 | 106 | { |
| 107 | - foreach ($collection->all() as $name => $route) { |
|
| 107 | + foreach ($collection->all() as $name => $route){ |
|
| 108 | 108 | $this->routes[$name] = $route; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function group(string $group) |
| 122 | 122 | { |
| 123 | - foreach ($this->routes as $route) { |
|
| 123 | + foreach ($this->routes as $route){ |
|
| 124 | 124 | $route->group($group); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -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 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function __construct( |
| 22 | 22 | private readonly FactoryInterface $factory |
| 23 | - ) { |
|
| 23 | + ){ |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -28,7 +28,7 @@ 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 | $this->groups[$name] = $this->factory->make(RouteGroup::class); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function registerRoutes(RouterInterface $router): void |
| 62 | 62 | { |
| 63 | - foreach ($this->groups as $group) { |
|
| 63 | + foreach ($this->groups as $group){ |
|
| 64 | 64 | $group->register($router, $this->factory); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -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 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | private readonly ClassLocatorByTarget $locator, |
| 18 | 18 | private readonly ListenerInvoker $invoker, |
| 19 | 19 | private readonly bool $readCache = true, |
| 20 | - ) { |
|
| 20 | + ){ |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function loadClasses(TokenizationListenerInterface $listener): bool |
@@ -25,7 +25,7 @@ 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 | return false; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | // We decided to load classes for each target separately. |
| 35 | 35 | // It allows us to cache classes for each target separately and if we reuse the |
| 36 | 36 | // same target in multiple listeners, we will not have to load classes for the same target. |
| 37 | - foreach ($targets as $target) { |
|
| 37 | + foreach ($targets as $target){ |
|
| 38 | 38 | $cacheKey = (string)$target; |
| 39 | 39 | |
| 40 | 40 | $classes = $this->readCache ? $this->memory->loadData($cacheKey) : null; |
| 41 | - if ($classes === null) { |
|
| 41 | + if ($classes === null){ |
|
| 42 | 42 | $this->memory->saveData( |
| 43 | 43 | $cacheKey, |
| 44 | 44 | $classes = $this->locator->getClasses($target), |
@@ -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), |