@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function all(): array |
| 59 | 59 | { |
| 60 | - try { |
|
| 60 | + try{ |
|
| 61 | 61 | return $this->dotGet(''); |
| 62 | - } catch (DotNotFoundException $e) { |
|
| 62 | + }catch (DotNotFoundException $e){ |
|
| 63 | 63 | return []; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | { |
| 86 | 86 | $result = array_intersect_key($this->all(), array_flip($keys)); |
| 87 | 87 | ; |
| 88 | - if (!$fill) { |
|
| 88 | + if (!$fill){ |
|
| 89 | 89 | return $result; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | public function has(string $name): bool |
| 110 | 110 | { |
| 111 | - try { |
|
| 111 | + try{ |
|
| 112 | 112 | $this->dotGet($name); |
| 113 | - } catch (DotNotFoundException $e) { |
|
| 113 | + }catch (DotNotFoundException $e){ |
|
| 114 | 114 | return false; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function get(string $name, $default = null) |
| 136 | 136 | { |
| 137 | - try { |
|
| 137 | + try{ |
|
| 138 | 138 | return $this->dotGet($name); |
| 139 | - } catch (DotNotFoundException $e) { |
|
| 139 | + }catch (DotNotFoundException $e){ |
|
| 140 | 140 | return $default; |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -174,15 +174,15 @@ discard block |
||
| 174 | 174 | $data = $this->data; |
| 175 | 175 | |
| 176 | 176 | //Generating path relative to a given name and prefix |
| 177 | - $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
|
| 178 | - if (empty($path)) { |
|
| 177 | + $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name; |
|
| 178 | + if (empty($path)){ |
|
| 179 | 179 | return $data; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $path = explode('.', rtrim($path, '.')); |
| 183 | 183 | |
| 184 | - foreach ($path as $step) { |
|
| 185 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
| 184 | + foreach ($path as $step){ |
|
| 185 | + if (!is_array($data) || !array_key_exists($step, $data)){ |
|
| 186 | 186 | throw new DotNotFoundException("Unable to find requested element '{$name}'"); |
| 187 | 187 | } |
| 188 | 188 | |
@@ -57,9 +57,12 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function all(): array |
| 59 | 59 | { |
| 60 | - try { |
|
| 60 | + try |
|
| 61 | + { |
|
| 61 | 62 | return $this->dotGet(''); |
| 62 | - } catch (DotNotFoundException $e) { |
|
| 63 | + } |
|
| 64 | + catch (DotNotFoundException $e) |
|
| 65 | + { |
|
| 63 | 66 | return []; |
| 64 | 67 | } |
| 65 | 68 | } |
@@ -85,7 +88,8 @@ discard block |
||
| 85 | 88 | { |
| 86 | 89 | $result = array_intersect_key($this->all(), array_flip($keys)); |
| 87 | 90 | ; |
| 88 | - if (!$fill) { |
|
| 91 | + if (!$fill) |
|
| 92 | + { |
|
| 89 | 93 | return $result; |
| 90 | 94 | } |
| 91 | 95 | |
@@ -108,9 +112,12 @@ discard block |
||
| 108 | 112 | */ |
| 109 | 113 | public function has(string $name): bool |
| 110 | 114 | { |
| 111 | - try { |
|
| 115 | + try |
|
| 116 | + { |
|
| 112 | 117 | $this->dotGet($name); |
| 113 | - } catch (DotNotFoundException $e) { |
|
| 118 | + } |
|
| 119 | + catch (DotNotFoundException $e) |
|
| 120 | + { |
|
| 114 | 121 | return false; |
| 115 | 122 | } |
| 116 | 123 | |
@@ -134,9 +141,12 @@ discard block |
||
| 134 | 141 | */ |
| 135 | 142 | public function get(string $name, $default = null) |
| 136 | 143 | { |
| 137 | - try { |
|
| 144 | + try |
|
| 145 | + { |
|
| 138 | 146 | return $this->dotGet($name); |
| 139 | - } catch (DotNotFoundException $e) { |
|
| 147 | + } |
|
| 148 | + catch (DotNotFoundException $e) |
|
| 149 | + { |
|
| 140 | 150 | return $default; |
| 141 | 151 | } |
| 142 | 152 | } |
@@ -175,14 +185,17 @@ discard block |
||
| 175 | 185 | |
| 176 | 186 | //Generating path relative to a given name and prefix |
| 177 | 187 | $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
| 178 | - if (empty($path)) { |
|
| 188 | + if (empty($path)) |
|
| 189 | + { |
|
| 179 | 190 | return $data; |
| 180 | 191 | } |
| 181 | 192 | |
| 182 | 193 | $path = explode('.', rtrim($path, '.')); |
| 183 | 194 | |
| 184 | - foreach ($path as $step) { |
|
| 185 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
| 195 | + foreach ($path as $step) |
|
| 196 | + { |
|
| 197 | + if (!is_array($data) || !array_key_exists($step, $data)) |
|
| 198 | + { |
|
| 186 | 199 | throw new DotNotFoundException("Unable to find requested element '{$name}'"); |
| 187 | 200 | } |
| 188 | 201 | |
@@ -388,7 +388,6 @@ discard block |
||
| 388 | 388 | /** |
| 389 | 389 | * @param string $name |
| 390 | 390 | * @param mixed $default |
| 391 | - |
|
| 392 | 391 | * @return mixed |
| 393 | 392 | */ |
| 394 | 393 | public function query(string $name, $default = null) |
@@ -399,7 +398,6 @@ discard block |
||
| 399 | 398 | /** |
| 400 | 399 | * @param string $name |
| 401 | 400 | * @param mixed $default |
| 402 | - |
|
| 403 | 401 | * @return mixed |
| 404 | 402 | */ |
| 405 | 403 | public function cookie(string $name, $default = null) |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $input = clone $this; |
| 145 | 145 | |
| 146 | - if ($add) { |
|
| 147 | - $input->prefix .= '.' . $prefix; |
|
| 146 | + if ($add){ |
|
| 147 | + $input->prefix .= '.'.$prefix; |
|
| 148 | 148 | $input->prefix = trim($input->prefix, '.'); |
| 149 | - } else { |
|
| 149 | + }else{ |
|
| 150 | 150 | $input->prefix = $prefix; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -162,12 +162,12 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $path = $this->uri()->getPath(); |
| 164 | 164 | |
| 165 | - if (empty($path)) { |
|
| 165 | + if (empty($path)){ |
|
| 166 | 166 | return '/'; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ($path[0] !== '/') { |
|
| 170 | - return '/' . $path; |
|
| 169 | + if ($path[0] !== '/'){ |
|
| 170 | + return '/'.$path; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $path; |
@@ -192,9 +192,9 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | public function request(): Request |
| 194 | 194 | { |
| 195 | - try { |
|
| 195 | + try{ |
|
| 196 | 196 | $request = $this->container->get(Request::class); |
| 197 | - } catch (ContainerExceptionInterface $e) { |
|
| 197 | + }catch (ContainerExceptionInterface $e){ |
|
| 198 | 198 | throw new ScopeException( |
| 199 | 199 | 'Unable to get `ServerRequestInterface` in active container scope', |
| 200 | 200 | $e->getCode(), |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | //Flushing input state |
| 206 | - if ($this->request !== $request) { |
|
| 206 | + if ($this->request !== $request){ |
|
| 207 | 207 | $this->bags = []; |
| 208 | 208 | $this->request = $request; |
| 209 | 209 | } |
@@ -265,16 +265,16 @@ discard block |
||
| 265 | 265 | public function isJsonExpected(bool $softMatch = false): bool |
| 266 | 266 | { |
| 267 | 267 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
| 268 | - foreach ($this->jsonTypes as $jsonType) { |
|
| 269 | - if ($acceptHeader->has($jsonType)) { |
|
| 268 | + foreach ($this->jsonTypes as $jsonType){ |
|
| 269 | + if ($acceptHeader->has($jsonType)){ |
|
| 270 | 270 | return true; |
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - if ($softMatch) { |
|
| 275 | - foreach ($acceptHeader->getAll() as $item) { |
|
| 274 | + if ($softMatch){ |
|
| 275 | + foreach ($acceptHeader->getAll() as $item){ |
|
| 276 | 276 | $itemValue = strtolower($item->getValue()); |
| 277 | - if (str_ends_with($itemValue, '/json') || str_ends_with($itemValue, '+json')) { |
|
| 277 | + if (str_ends_with($itemValue, '/json') || str_ends_with($itemValue, '+json')){ |
|
| 278 | 278 | return true; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -321,18 +321,18 @@ discard block |
||
| 321 | 321 | // ensure proper request association |
| 322 | 322 | $this->request(); |
| 323 | 323 | |
| 324 | - if (isset($this->bags[$name])) { |
|
| 324 | + if (isset($this->bags[$name])){ |
|
| 325 | 325 | return $this->bags[$name]; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if (!isset($this->bagAssociations[$name])) { |
|
| 328 | + if (!isset($this->bagAssociations[$name])){ |
|
| 329 | 329 | throw new InputException("Undefined input bag '{$name}'"); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $class = $this->bagAssociations[$name]['class']; |
| 333 | 333 | $data = call_user_func([$this->request(), $this->bagAssociations[$name]['source']]); |
| 334 | 334 | |
| 335 | - if (!is_array($data)) { |
|
| 335 | + if (!is_array($data)){ |
|
| 336 | 336 | $data = (array)$data; |
| 337 | 337 | } |
| 338 | 338 | |
@@ -143,10 +143,13 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $input = clone $this; |
| 145 | 145 | |
| 146 | - if ($add) { |
|
| 146 | + if ($add) |
|
| 147 | + { |
|
| 147 | 148 | $input->prefix .= '.' . $prefix; |
| 148 | 149 | $input->prefix = trim($input->prefix, '.'); |
| 149 | - } else { |
|
| 150 | + } |
|
| 151 | + else |
|
| 152 | + { |
|
| 150 | 153 | $input->prefix = $prefix; |
| 151 | 154 | } |
| 152 | 155 | |
@@ -162,11 +165,13 @@ discard block |
||
| 162 | 165 | { |
| 163 | 166 | $path = $this->uri()->getPath(); |
| 164 | 167 | |
| 165 | - if (empty($path)) { |
|
| 168 | + if (empty($path)) |
|
| 169 | + { |
|
| 166 | 170 | return '/'; |
| 167 | 171 | } |
| 168 | 172 | |
| 169 | - if ($path[0] !== '/') { |
|
| 173 | + if ($path[0] !== '/') |
|
| 174 | + { |
|
| 170 | 175 | return '/' . $path; |
| 171 | 176 | } |
| 172 | 177 | |
@@ -192,9 +197,12 @@ discard block |
||
| 192 | 197 | */ |
| 193 | 198 | public function request(): Request |
| 194 | 199 | { |
| 195 | - try { |
|
| 200 | + try |
|
| 201 | + { |
|
| 196 | 202 | $request = $this->container->get(Request::class); |
| 197 | - } catch (ContainerExceptionInterface $e) { |
|
| 203 | + } |
|
| 204 | + catch (ContainerExceptionInterface $e) |
|
| 205 | + { |
|
| 198 | 206 | throw new ScopeException( |
| 199 | 207 | 'Unable to get `ServerRequestInterface` in active container scope', |
| 200 | 208 | $e->getCode(), |
@@ -203,7 +211,8 @@ discard block |
||
| 203 | 211 | } |
| 204 | 212 | |
| 205 | 213 | //Flushing input state |
| 206 | - if ($this->request !== $request) { |
|
| 214 | + if ($this->request !== $request) |
|
| 215 | + { |
|
| 207 | 216 | $this->bags = []; |
| 208 | 217 | $this->request = $request; |
| 209 | 218 | } |
@@ -265,16 +274,21 @@ discard block |
||
| 265 | 274 | public function isJsonExpected(bool $softMatch = false): bool |
| 266 | 275 | { |
| 267 | 276 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
| 268 | - foreach ($this->jsonTypes as $jsonType) { |
|
| 269 | - if ($acceptHeader->has($jsonType)) { |
|
| 277 | + foreach ($this->jsonTypes as $jsonType) |
|
| 278 | + { |
|
| 279 | + if ($acceptHeader->has($jsonType)) |
|
| 280 | + { |
|
| 270 | 281 | return true; |
| 271 | 282 | } |
| 272 | 283 | } |
| 273 | 284 | |
| 274 | - if ($softMatch) { |
|
| 275 | - foreach ($acceptHeader->getAll() as $item) { |
|
| 285 | + if ($softMatch) |
|
| 286 | + { |
|
| 287 | + foreach ($acceptHeader->getAll() as $item) |
|
| 288 | + { |
|
| 276 | 289 | $itemValue = strtolower($item->getValue()); |
| 277 | - if (str_ends_with($itemValue, '/json') || str_ends_with($itemValue, '+json')) { |
|
| 290 | + if (str_ends_with($itemValue, '/json') || str_ends_with($itemValue, '+json')) |
|
| 291 | + { |
|
| 278 | 292 | return true; |
| 279 | 293 | } |
| 280 | 294 | } |
@@ -321,18 +335,21 @@ discard block |
||
| 321 | 335 | // ensure proper request association |
| 322 | 336 | $this->request(); |
| 323 | 337 | |
| 324 | - if (isset($this->bags[$name])) { |
|
| 338 | + if (isset($this->bags[$name])) |
|
| 339 | + { |
|
| 325 | 340 | return $this->bags[$name]; |
| 326 | 341 | } |
| 327 | 342 | |
| 328 | - if (!isset($this->bagAssociations[$name])) { |
|
| 343 | + if (!isset($this->bagAssociations[$name])) |
|
| 344 | + { |
|
| 329 | 345 | throw new InputException("Undefined input bag '{$name}'"); |
| 330 | 346 | } |
| 331 | 347 | |
| 332 | 348 | $class = $this->bagAssociations[$name]['class']; |
| 333 | 349 | $data = call_user_func([$this->request(), $this->bagAssociations[$name]['source']]); |
| 334 | 350 | |
| 335 | - if (!is_array($data)) { |
|
| 351 | + if (!is_array($data)) |
|
| 352 | + { |
|
| 336 | 353 | $data = (array)$data; |
| 337 | 354 | } |
| 338 | 355 | |
@@ -30,7 +30,6 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * |
| 32 | 32 | * @param bool|string $implode Implode header lines, false to return header as array. |
| 33 | - |
|
| 34 | 33 | * @return string|array |
| 35 | 34 | */ |
| 36 | 35 | public function get(string $name, $default = null, $implode = ',') |
@@ -69,7 +68,6 @@ discard block |
||
| 69 | 68 | * Normalize header name. |
| 70 | 69 | * |
| 71 | 70 | * @param string $header |
| 72 | - |
|
| 73 | 71 | * @return string |
| 74 | 72 | */ |
| 75 | 73 | protected function normalize(string $header): string |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $value = parent::get($this->normalize($name), $default); |
| 39 | 39 | |
| 40 | - if (!empty($implode) && is_array($value)) { |
|
| 40 | + if (!empty($implode) && is_array($value)){ |
|
| 41 | 41 | return implode($implode, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $values = parent::fetch($keys, $fill, $filler); |
| 57 | 57 | |
| 58 | - if (!empty($implode)) { |
|
| 59 | - foreach ($values as &$value) { |
|
| 58 | + if (!empty($implode)){ |
|
| 59 | + foreach ($values as &$value){ |
|
| 60 | 60 | $value = implode($implode, $value); |
| 61 | 61 | unset($value); |
| 62 | 62 | } |
@@ -37,7 +37,8 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | $value = parent::get($this->normalize($name), $default); |
| 39 | 39 | |
| 40 | - if (!empty($implode) && is_array($value)) { |
|
| 40 | + if (!empty($implode) && is_array($value)) |
|
| 41 | + { |
|
| 41 | 42 | return implode($implode, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -55,8 +56,10 @@ discard block |
||
| 55 | 56 | |
| 56 | 57 | $values = parent::fetch($keys, $fill, $filler); |
| 57 | 58 | |
| 58 | - if (!empty($implode)) { |
|
| 59 | - foreach ($values as &$value) { |
|
| 59 | + if (!empty($implode)) |
|
| 60 | + { |
|
| 61 | + foreach ($values as &$value) |
|
| 62 | + { |
|
| 60 | 63 | $value = implode($implode, $value); |
| 61 | 64 | unset($value); |
| 62 | 65 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ResponseFactoryInterface $responseFactory, |
| 47 | 47 | StreamFactoryInterface $streamFactory, |
| 48 | 48 | FilesInterface $files |
| 49 | - ) { |
|
| 49 | + ){ |
|
| 50 | 50 | $this->responseFactory = $responseFactory; |
| 51 | 51 | $this->streamFactory = $streamFactory; |
| 52 | 52 | $this->files = $files; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function redirect($uri, int $code = 302): ResponseInterface |
| 74 | 74 | { |
| 75 | - if (!is_string($uri) && !$uri instanceof UriInterface) { |
|
| 75 | + if (!is_string($uri) && !$uri instanceof UriInterface){ |
|
| 76 | 76 | throw new ResponseException('Redirect allowed only for string or UriInterface uris'); |
| 77 | 77 | } |
| 78 | 78 | |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | string $name = '', |
| 109 | 109 | string $mime = 'application/octet-stream' |
| 110 | 110 | ): ResponseInterface { |
| 111 | - if (empty($name)) { |
|
| 112 | - if (!is_string($filename)) { |
|
| 111 | + if (empty($name)){ |
|
| 112 | + if (!is_string($filename)){ |
|
| 113 | 113 | throw new ResponseException('Unable to resolve public filename'); |
| 114 | 114 | } |
| 115 | 115 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $response = $response->withHeader('Content-Length', (string)$stream->getSize()); |
| 124 | 124 | $response = $response->withHeader( |
| 125 | 125 | 'Content-Disposition', |
| 126 | - 'attachment; filename="' . addcslashes($name, '"') . '"' |
|
| 126 | + 'attachment; filename="'.addcslashes($name, '"').'"' |
|
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | return $response->withBody($stream); |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | private function getStream($file): StreamInterface |
| 158 | 158 | { |
| 159 | - if ($file instanceof StreamableInterface) { |
|
| 159 | + if ($file instanceof StreamableInterface){ |
|
| 160 | 160 | return $file->getStream(); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ($file instanceof StreamInterface) { |
|
| 163 | + if ($file instanceof StreamInterface){ |
|
| 164 | 164 | return $file; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if (is_resource($file)) { |
|
| 167 | + if (is_resource($file)){ |
|
| 168 | 168 | return $this->streamFactory->createStreamFromResource($file); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (!$this->files->isFile($file)) { |
|
| 171 | + if (!$this->files->isFile($file)){ |
|
| 172 | 172 | throw new ResponseException('Unable to allocate response body stream, file does not exist'); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -72,7 +72,8 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function redirect($uri, int $code = 302): ResponseInterface |
| 74 | 74 | { |
| 75 | - if (!is_string($uri) && !$uri instanceof UriInterface) { |
|
| 75 | + if (!is_string($uri) && !$uri instanceof UriInterface) |
|
| 76 | + { |
|
| 76 | 77 | throw new ResponseException('Redirect allowed only for string or UriInterface uris'); |
| 77 | 78 | } |
| 78 | 79 | |
@@ -108,8 +109,10 @@ discard block |
||
| 108 | 109 | string $name = '', |
| 109 | 110 | string $mime = 'application/octet-stream' |
| 110 | 111 | ): ResponseInterface { |
| 111 | - if (empty($name)) { |
|
| 112 | - if (!is_string($filename)) { |
|
| 112 | + if (empty($name)) |
|
| 113 | + { |
|
| 114 | + if (!is_string($filename)) |
|
| 115 | + { |
|
| 113 | 116 | throw new ResponseException('Unable to resolve public filename'); |
| 114 | 117 | } |
| 115 | 118 | |
@@ -156,19 +159,23 @@ discard block |
||
| 156 | 159 | */ |
| 157 | 160 | private function getStream($file): StreamInterface |
| 158 | 161 | { |
| 159 | - if ($file instanceof StreamableInterface) { |
|
| 162 | + if ($file instanceof StreamableInterface) |
|
| 163 | + { |
|
| 160 | 164 | return $file->getStream(); |
| 161 | 165 | } |
| 162 | 166 | |
| 163 | - if ($file instanceof StreamInterface) { |
|
| 167 | + if ($file instanceof StreamInterface) |
|
| 168 | + { |
|
| 164 | 169 | return $file; |
| 165 | 170 | } |
| 166 | 171 | |
| 167 | - if (is_resource($file)) { |
|
| 172 | + if (is_resource($file)) |
|
| 173 | + { |
|
| 168 | 174 | return $this->streamFactory->createStreamFromResource($file); |
| 169 | 175 | } |
| 170 | 176 | |
| 171 | - if (!$this->files->isFile($file)) { |
|
| 177 | + if (!$this->files->isFile($file)) |
|
| 178 | + { |
|
| 172 | 179 | throw new ResponseException('Unable to allocate response body stream, file does not exist'); |
| 173 | 180 | } |
| 174 | 181 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | public function setUp(): void |
| 22 | 22 | { |
| 23 | 23 | exec('protoc 2>&1', $out); |
| 24 | - if (strpos(implode("\n", $out), '--php_out') === false) { |
|
| 24 | + if (strpos(implode("\n", $out), '--php_out') === false){ |
|
| 25 | 25 | $this->markTestSkipped('Protoc binary is missing'); |
| 26 | 26 | return; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | parent::setUp(); |
| 30 | 30 | |
| 31 | 31 | $fs = new Files(); |
| 32 | - $this->proto = $fs->normalizePath($this->app->dir('app') . 'proto/service.proto'); |
|
| 32 | + $this->proto = $fs->normalizePath($this->app->dir('app').'proto/service.proto'); |
|
| 33 | 33 | |
| 34 | 34 | // protoc can't figure relative paths |
| 35 | 35 | $this->proto = str_replace('Framework/../', '', $this->proto); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | $fs = new Files(); |
| 43 | 43 | |
| 44 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 45 | - $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
|
| 44 | + if ($fs->isDirectory($this->app->dir('app').'src/Service')){ |
|
| 45 | + $fs->deleteDirectory($this->app->dir('app').'src/Service'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 49 | - $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
|
| 48 | + if ($fs->isDirectory($this->app->dir('app').'src/GPBMetadata')){ |
|
| 49 | + $fs->deleteDirectory($this->app->dir('app').'src/GPBMetadata'); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | 'proto' => $this->proto |
| 64 | 64 | ]); |
| 65 | 65 | |
| 66 | - $output = $this->app->dir('app') . 'src/Service/EchoService.php'; |
|
| 66 | + $output = $this->app->dir('app').'src/Service/EchoService.php'; |
|
| 67 | 67 | file_put_contents($output, GenerateTest::SERVICE); |
| 68 | 68 | |
| 69 | 69 | $out = $this->runCommandDebug('grpc:services'); |
@@ -21,7 +21,8 @@ discard block |
||
| 21 | 21 | public function setUp(): void |
| 22 | 22 | { |
| 23 | 23 | exec('protoc 2>&1', $out); |
| 24 | - if (strpos(implode("\n", $out), '--php_out') === false) { |
|
| 24 | + if (strpos(implode("\n", $out), '--php_out') === false) |
|
| 25 | + { |
|
| 25 | 26 | $this->markTestSkipped('Protoc binary is missing'); |
| 26 | 27 | return; |
| 27 | 28 | } |
@@ -41,11 +42,13 @@ discard block |
||
| 41 | 42 | |
| 42 | 43 | $fs = new Files(); |
| 43 | 44 | |
| 44 | - if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) { |
|
| 45 | + if ($fs->isDirectory($this->app->dir('app') . 'src/Service')) |
|
| 46 | + { |
|
| 45 | 47 | $fs->deleteDirectory($this->app->dir('app') . 'src/Service'); |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | - if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) { |
|
| 50 | + if ($fs->isDirectory($this->app->dir('app') . 'src/GPBMetadata')) |
|
| 51 | + { |
|
| 49 | 52 | $fs->deleteDirectory($this->app->dir('app') . 'src/GPBMetadata'); |
| 50 | 53 | } |
| 51 | 54 | } |
@@ -127,9 +127,9 @@ |
||
| 127 | 127 | $cookie = new Cookie('', '', 0, '', '', $secure, false, $sameSite); |
| 128 | 128 | $this->assertSame($expected, $cookie->getSameSite()); |
| 129 | 129 | |
| 130 | - if ($expected === null) { |
|
| 130 | + if ($expected === null){ |
|
| 131 | 131 | $this->assertStringNotContainsString('SameSite=', $cookie->createHeader()); |
| 132 | - } else { |
|
| 132 | + }else{ |
|
| 133 | 133 | $this->assertStringContainsString("SameSite=$expected", $cookie->createHeader()); |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -127,9 +127,12 @@ |
||
| 127 | 127 | $cookie = new Cookie('', '', 0, '', '', $secure, false, $sameSite); |
| 128 | 128 | $this->assertSame($expected, $cookie->getSameSite()); |
| 129 | 129 | |
| 130 | - if ($expected === null) { |
|
| 130 | + if ($expected === null) |
|
| 131 | + { |
|
| 131 | 132 | $this->assertStringNotContainsString('SameSite=', $cookie->createHeader()); |
| 132 | - } else { |
|
| 133 | + } |
|
| 134 | + else |
|
| 135 | + { |
|
| 133 | 136 | $this->assertStringContainsString("SameSite=$expected", $cookie->createHeader()); |
| 134 | 137 | } |
| 135 | 138 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function testScope(): void |
| 57 | 57 | { |
| 58 | 58 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 59 | - $core->setHandler(function ($r) { |
|
| 59 | + $core->setHandler(function ($r){ |
|
| 60 | 60 | $this->assertInstanceOf( |
| 61 | 61 | CookieQueue::class, |
| 62 | 62 | $this->container->get(ServerRequestInterface::class) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | public function testSetEncryptedCookie(): void |
| 81 | 81 | { |
| 82 | 82 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 83 | - $core->setHandler(function ($r) { |
|
| 83 | + $core->setHandler(function ($r){ |
|
| 84 | 84 | $this->container->get(ServerRequestInterface::class) |
| 85 | 85 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 86 | 86 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public function testSetNotProtectedCookie(): void |
| 103 | 103 | { |
| 104 | 104 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 105 | - $core->setHandler(function ($r) { |
|
| 105 | + $core->setHandler(function ($r){ |
|
| 106 | 106 | $this->container->get(ServerRequestInterface::class) |
| 107 | 107 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
| 108 | 108 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | public function testDecrypt(): void |
| 122 | 122 | { |
| 123 | 123 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 124 | - $core->setHandler(function ($r) { |
|
| 124 | + $core->setHandler(function ($r){ |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * @var ServerRequest $r |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function testDecryptArray(): void |
| 140 | 140 | { |
| 141 | 141 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 142 | - $core->setHandler(function ($r) { |
|
| 142 | + $core->setHandler(function ($r){ |
|
| 143 | 143 | |
| 144 | 144 | /** |
| 145 | 145 | * @var ServerRequest $r |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | public function testDecryptBroken(): void |
| 158 | 158 | { |
| 159 | 159 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 160 | - $core->setHandler(function ($r) { |
|
| 160 | + $core->setHandler(function ($r){ |
|
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * @var ServerRequest $r |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | return $r->getCookieParams()['name']; |
| 166 | 166 | }); |
| 167 | 167 | |
| 168 | - $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value') . 'BROKEN'; |
|
| 168 | + $value = $this->container->get(EncrypterInterface::class)->encrypt('cookie-value').'BROKEN'; |
|
| 169 | 169 | |
| 170 | 170 | $response = $this->get($core, '/', [], [], ['name' => $value]); |
| 171 | 171 | $this->assertSame(200, $response->getStatusCode()); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function testDelete(): void |
| 176 | 176 | { |
| 177 | 177 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 178 | - $core->setHandler(function ($r) { |
|
| 178 | + $core->setHandler(function ($r){ |
|
| 179 | 179 | $this->container->get(ServerRequestInterface::class) |
| 180 | 180 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 181 | 181 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | ])); |
| 204 | 204 | |
| 205 | 205 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 206 | - $core->setHandler(function ($r) { |
|
| 206 | + $core->setHandler(function ($r){ |
|
| 207 | 207 | $this->container->get(ServerRequestInterface::class) |
| 208 | 208 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 209 | 209 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | ])); |
| 229 | 229 | |
| 230 | 230 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 231 | - $core->setHandler(function ($r) { |
|
| 231 | + $core->setHandler(function ($r){ |
|
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | 234 | * @var ServerRequest $r |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | ])); |
| 253 | 253 | |
| 254 | 254 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 255 | - $core->setHandler(function ($r) { |
|
| 255 | + $core->setHandler(function ($r){ |
|
| 256 | 256 | $this->container->get(ServerRequestInterface::class) |
| 257 | 257 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 258 | 258 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | $cookies = $this->fetchCookies($response); |
| 267 | 267 | $this->assertArrayHasKey('name', $cookies); |
| 268 | 268 | |
| 269 | - $core->setHandler(function ($r) { |
|
| 269 | + $core->setHandler(function ($r){ |
|
| 270 | 270 | return $r->getCookieParams()['name']; |
| 271 | 271 | }); |
| 272 | 272 | |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | { |
| 327 | 327 | $result = []; |
| 328 | 328 | |
| 329 | - foreach ($response->getHeaders() as $line) { |
|
| 329 | + foreach ($response->getHeaders() as $line){ |
|
| 330 | 330 | $cookie = explode('=', implode('', $line)); |
| 331 | 331 | $result[$cookie[0]] = rawurldecode(substr( |
| 332 | 332 | (string)$cookie[1], |
@@ -56,7 +56,8 @@ discard block |
||
| 56 | 56 | public function testScope(): void |
| 57 | 57 | { |
| 58 | 58 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 59 | - $core->setHandler(function ($r) { |
|
| 59 | + $core->setHandler(function ($r) |
|
| 60 | + { |
|
| 60 | 61 | $this->assertInstanceOf( |
| 61 | 62 | CookieQueue::class, |
| 62 | 63 | $this->container->get(ServerRequestInterface::class) |
@@ -80,7 +81,8 @@ discard block |
||
| 80 | 81 | public function testSetEncryptedCookie(): void |
| 81 | 82 | { |
| 82 | 83 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 83 | - $core->setHandler(function ($r) { |
|
| 84 | + $core->setHandler(function ($r) |
|
| 85 | + { |
|
| 84 | 86 | $this->container->get(ServerRequestInterface::class) |
| 85 | 87 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 86 | 88 | |
@@ -102,7 +104,8 @@ discard block |
||
| 102 | 104 | public function testSetNotProtectedCookie(): void |
| 103 | 105 | { |
| 104 | 106 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 105 | - $core->setHandler(function ($r) { |
|
| 107 | + $core->setHandler(function ($r) |
|
| 108 | + { |
|
| 106 | 109 | $this->container->get(ServerRequestInterface::class) |
| 107 | 110 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('PHPSESSID', 'value'); |
| 108 | 111 | |
@@ -121,7 +124,8 @@ discard block |
||
| 121 | 124 | public function testDecrypt(): void |
| 122 | 125 | { |
| 123 | 126 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 124 | - $core->setHandler(function ($r) { |
|
| 127 | + $core->setHandler(function ($r) |
|
| 128 | + { |
|
| 125 | 129 | |
| 126 | 130 | /** |
| 127 | 131 | * @var ServerRequest $r |
@@ -139,7 +143,8 @@ discard block |
||
| 139 | 143 | public function testDecryptArray(): void |
| 140 | 144 | { |
| 141 | 145 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 142 | - $core->setHandler(function ($r) { |
|
| 146 | + $core->setHandler(function ($r) |
|
| 147 | + { |
|
| 143 | 148 | |
| 144 | 149 | /** |
| 145 | 150 | * @var ServerRequest $r |
@@ -157,7 +162,8 @@ discard block |
||
| 157 | 162 | public function testDecryptBroken(): void |
| 158 | 163 | { |
| 159 | 164 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 160 | - $core->setHandler(function ($r) { |
|
| 165 | + $core->setHandler(function ($r) |
|
| 166 | + { |
|
| 161 | 167 | |
| 162 | 168 | /** |
| 163 | 169 | * @var ServerRequest $r |
@@ -175,7 +181,8 @@ discard block |
||
| 175 | 181 | public function testDelete(): void |
| 176 | 182 | { |
| 177 | 183 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 178 | - $core->setHandler(function ($r) { |
|
| 184 | + $core->setHandler(function ($r) |
|
| 185 | + { |
|
| 179 | 186 | $this->container->get(ServerRequestInterface::class) |
| 180 | 187 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 181 | 188 | |
@@ -203,7 +210,8 @@ discard block |
||
| 203 | 210 | ])); |
| 204 | 211 | |
| 205 | 212 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 206 | - $core->setHandler(function ($r) { |
|
| 213 | + $core->setHandler(function ($r) |
|
| 214 | + { |
|
| 207 | 215 | $this->container->get(ServerRequestInterface::class) |
| 208 | 216 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 209 | 217 | |
@@ -228,7 +236,8 @@ discard block |
||
| 228 | 236 | ])); |
| 229 | 237 | |
| 230 | 238 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 231 | - $core->setHandler(function ($r) { |
|
| 239 | + $core->setHandler(function ($r) |
|
| 240 | + { |
|
| 232 | 241 | |
| 233 | 242 | /** |
| 234 | 243 | * @var ServerRequest $r |
@@ -252,7 +261,8 @@ discard block |
||
| 252 | 261 | ])); |
| 253 | 262 | |
| 254 | 263 | $core = $this->httpCore([CookiesMiddleware::class]); |
| 255 | - $core->setHandler(function ($r) { |
|
| 264 | + $core->setHandler(function ($r) |
|
| 265 | + { |
|
| 256 | 266 | $this->container->get(ServerRequestInterface::class) |
| 257 | 267 | ->getAttribute(CookieQueue::ATTRIBUTE)->set('name', 'value'); |
| 258 | 268 | |
@@ -266,7 +276,8 @@ discard block |
||
| 266 | 276 | $cookies = $this->fetchCookies($response); |
| 267 | 277 | $this->assertArrayHasKey('name', $cookies); |
| 268 | 278 | |
| 269 | - $core->setHandler(function ($r) { |
|
| 279 | + $core->setHandler(function ($r) |
|
| 280 | + { |
|
| 270 | 281 | return $r->getCookieParams()['name']; |
| 271 | 282 | }); |
| 272 | 283 | |
@@ -326,7 +337,8 @@ discard block |
||
| 326 | 337 | { |
| 327 | 338 | $result = []; |
| 328 | 339 | |
| 329 | - foreach ($response->getHeaders() as $line) { |
|
| 340 | + foreach ($response->getHeaders() as $line) |
|
| 341 | + { |
|
| 330 | 342 | $cookie = explode('=', implode('', $line)); |
| 331 | 343 | $result[$cookie[0]] = rawurldecode(substr( |
| 332 | 344 | (string)$cookie[1], |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value){ |
|
| 41 | 41 | $response = $response->withAddedHeader($header, $value); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -37,7 +37,8 @@ |
||
| 37 | 37 | $response = new Response('php://memory', $code, []); |
| 38 | 38 | $response = $response->withStatus($code, $reasonPhrase); |
| 39 | 39 | |
| 40 | - foreach ($this->config->getBaseHeaders() as $header => $value) { |
|
| 40 | + foreach ($this->config->getBaseHeaders() as $header => $value) |
|
| 41 | + { |
|
| 41 | 42 | $response = $response->withAddedHeader($header, $value); |
| 42 | 43 | } |
| 43 | 44 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | bool $secure = false, |
| 130 | 130 | bool $httpOnly = true, |
| 131 | 131 | ?string $sameSite = null |
| 132 | - ) { |
|
| 132 | + ){ |
|
| 133 | 133 | $this->name = $name; |
| 134 | 134 | $this->value = $value; |
| 135 | 135 | $this->lifetime = $lifetime; |
@@ -253,30 +253,30 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function createHeader(): string |
| 255 | 255 | { |
| 256 | - $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)]; |
|
| 256 | + $header = [rawurlencode($this->name).'='.rawurlencode((string)$this->value)]; |
|
| 257 | 257 | |
| 258 | - if ($this->lifetime !== null) { |
|
| 259 | - $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
| 258 | + if ($this->lifetime !== null){ |
|
| 259 | + $header[] = 'Expires='.gmdate(\DateTime::COOKIE, $this->getExpires()); |
|
| 260 | 260 | $header[] = "Max-Age={$this->lifetime}"; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | - if (!empty($this->path)) { |
|
| 263 | + if (!empty($this->path)){ |
|
| 264 | 264 | $header[] = "Path={$this->path}"; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - if (!empty($this->domain)) { |
|
| 267 | + if (!empty($this->domain)){ |
|
| 268 | 268 | $header[] = "Domain={$this->domain}"; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if ($this->secure) { |
|
| 271 | + if ($this->secure){ |
|
| 272 | 272 | $header[] = 'Secure'; |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - if ($this->httpOnly) { |
|
| 275 | + if ($this->httpOnly){ |
|
| 276 | 276 | $header[] = 'HttpOnly'; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - if ($this->sameSite->get() !== null) { |
|
| 279 | + if ($this->sameSite->get() !== null){ |
|
| 280 | 280 | $header[] = "SameSite={$this->sameSite->get()}"; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | */ |
| 293 | 293 | public function getExpires(): ?int |
| 294 | 294 | { |
| 295 | - if ($this->lifetime === null) { |
|
| 295 | + if ($this->lifetime === null){ |
|
| 296 | 296 | return null; |
| 297 | 297 | } |
| 298 | 298 | |
@@ -255,28 +255,34 @@ discard block |
||
| 255 | 255 | { |
| 256 | 256 | $header = [rawurlencode($this->name) . '=' . rawurlencode((string)$this->value)]; |
| 257 | 257 | |
| 258 | - if ($this->lifetime !== null) { |
|
| 258 | + if ($this->lifetime !== null) |
|
| 259 | + { |
|
| 259 | 260 | $header[] = 'Expires=' . gmdate(\DateTime::COOKIE, $this->getExpires()); |
| 260 | 261 | $header[] = "Max-Age={$this->lifetime}"; |
| 261 | 262 | } |
| 262 | 263 | |
| 263 | - if (!empty($this->path)) { |
|
| 264 | + if (!empty($this->path)) |
|
| 265 | + { |
|
| 264 | 266 | $header[] = "Path={$this->path}"; |
| 265 | 267 | } |
| 266 | 268 | |
| 267 | - if (!empty($this->domain)) { |
|
| 269 | + if (!empty($this->domain)) |
|
| 270 | + { |
|
| 268 | 271 | $header[] = "Domain={$this->domain}"; |
| 269 | 272 | } |
| 270 | 273 | |
| 271 | - if ($this->secure) { |
|
| 274 | + if ($this->secure) |
|
| 275 | + { |
|
| 272 | 276 | $header[] = 'Secure'; |
| 273 | 277 | } |
| 274 | 278 | |
| 275 | - if ($this->httpOnly) { |
|
| 279 | + if ($this->httpOnly) |
|
| 280 | + { |
|
| 276 | 281 | $header[] = 'HttpOnly'; |
| 277 | 282 | } |
| 278 | 283 | |
| 279 | - if ($this->sameSite->get() !== null) { |
|
| 284 | + if ($this->sameSite->get() !== null) |
|
| 285 | + { |
|
| 280 | 286 | $header[] = "SameSite={$this->sameSite->get()}"; |
| 281 | 287 | } |
| 282 | 288 | |
@@ -292,7 +298,8 @@ discard block |
||
| 292 | 298 | */ |
| 293 | 299 | public function getExpires(): ?int |
| 294 | 300 | { |
| 295 | - if ($this->lifetime === null) { |
|
| 301 | + if ($this->lifetime === null) |
|
| 302 | + { |
|
| 296 | 303 | return null; |
| 297 | 304 | } |
| 298 | 305 | |