@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly ViewsInterface $views, |
| 18 | - ) {} |
|
| 18 | + ){} |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Copy-pasted form https://stackoverflow.com/a/20806227 |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public static function escapeSubject(string $subject): string |
| 28 | 28 | { |
| 29 | - if (!\preg_match('/[^\x20-\x7e]/', $subject)) { |
|
| 29 | + if (!\preg_match('/[^\x20-\x7e]/', $subject)){ |
|
| 30 | 30 | // ascii-only subject, return as-is |
| 31 | 31 | return $subject; |
| 32 | 32 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | $prefix = '=?UTF-8?B?'; |
| 37 | 37 | $suffix = '?='; |
| 38 | 38 | |
| 39 | - return $prefix . \str_replace("=\r\n", $suffix . "\r\n " . $prefix, $encoded) . $suffix; |
|
| 39 | + return $prefix.\str_replace("=\r\n", $suffix."\r\n ".$prefix, $encoded).$suffix; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function render(MessageInterface $message): Email |
| 43 | 43 | { |
| 44 | - try { |
|
| 44 | + try{ |
|
| 45 | 45 | $view = $this->views->get($message->getSubject()); |
| 46 | - } catch (ViewException $e) { |
|
| 46 | + }catch (ViewException $e){ |
|
| 47 | 47 | throw new MailerException( |
| 48 | 48 | \sprintf('Invalid email template `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 49 | 49 | $e->getCode(), |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $msg = new Email(); |
| 55 | 55 | |
| 56 | - if ($message->getFrom() !== null) { |
|
| 56 | + if ($message->getFrom() !== null){ |
|
| 57 | 57 | $msg->from($message->getFrom()); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | $msg->cc(...$message->getCC()); |
| 62 | 62 | $msg->bcc(...$message->getBCC()); |
| 63 | 63 | |
| 64 | - try { |
|
| 64 | + try{ |
|
| 65 | 65 | // render message partials |
| 66 | 66 | $view->render(\array_merge(['_msg_' => $msg], $message->getData())); |
| 67 | - } catch (ViewException $e) { |
|
| 67 | + }catch (ViewException $e){ |
|
| 68 | 68 | throw new MailerException( |
| 69 | 69 | \sprintf('Unable to render email `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 70 | 70 | $e->getCode(), |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly ViewsInterface $views, |
| 18 | - ) {} |
|
| 18 | + ) { |
|
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Copy-pasted form https://stackoverflow.com/a/20806227 |
@@ -26,7 +27,8 @@ discard block |
||
| 26 | 27 | */ |
| 27 | 28 | public static function escapeSubject(string $subject): string |
| 28 | 29 | { |
| 29 | - if (!\preg_match('/[^\x20-\x7e]/', $subject)) { |
|
| 30 | + if (!\preg_match('/[^\x20-\x7e]/', $subject)) |
|
| 31 | + { |
|
| 30 | 32 | // ascii-only subject, return as-is |
| 31 | 33 | return $subject; |
| 32 | 34 | } |
@@ -41,9 +43,12 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function render(MessageInterface $message): Email |
| 43 | 45 | { |
| 44 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 45 | 48 | $view = $this->views->get($message->getSubject()); |
| 46 | - } catch (ViewException $e) { |
|
| 49 | + } |
|
| 50 | + catch (ViewException $e) |
|
| 51 | + { |
|
| 47 | 52 | throw new MailerException( |
| 48 | 53 | \sprintf('Invalid email template `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 49 | 54 | $e->getCode(), |
@@ -53,7 +58,8 @@ discard block |
||
| 53 | 58 | |
| 54 | 59 | $msg = new Email(); |
| 55 | 60 | |
| 56 | - if ($message->getFrom() !== null) { |
|
| 61 | + if ($message->getFrom() !== null) |
|
| 62 | + { |
|
| 57 | 63 | $msg->from($message->getFrom()); |
| 58 | 64 | } |
| 59 | 65 | |
@@ -61,10 +67,13 @@ discard block |
||
| 61 | 67 | $msg->cc(...$message->getCC()); |
| 62 | 68 | $msg->bcc(...$message->getBCC()); |
| 63 | 69 | |
| 64 | - try { |
|
| 70 | + try |
|
| 71 | + { |
|
| 65 | 72 | // render message partials |
| 66 | 73 | $view->render(\array_merge(['_msg_' => $msg], $message->getData())); |
| 67 | - } catch (ViewException $e) { |
|
| 74 | + } |
|
| 75 | + catch (ViewException $e) |
|
| 76 | + { |
|
| 68 | 77 | throw new MailerException( |
| 69 | 78 | \sprintf('Unable to render email `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 70 | 79 | $e->getCode(), |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $this->container->bind(ServerRequestInterface::class, $request); |
| 162 | 162 | |
| 163 | - self::assertSame(['PATH' => 'sample',], $this->input->server->__debugInfo()); |
|
| 163 | + self::assertSame(['PATH' => 'sample', ], $this->input->server->__debugInfo()); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | public function testIterator(): void |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $this->container->bind(ServerRequestInterface::class, $request); |
| 175 | 175 | |
| 176 | - self::assertSame(['PATH' => 'sample',], \iterator_to_array($this->input->server)); |
|
| 176 | + self::assertSame(['PATH' => 'sample', ], \iterator_to_array($this->input->server)); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | public function testSetAndExceptions(): void |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'message' => 'hi', |
| 34 | 34 | ]); |
| 35 | 35 | |
| 36 | - self::assertSame('{"status":300,"message":"hi"}', (string) $response->getBody()); |
|
| 36 | + self::assertSame('{"status":300,"message":"hi"}', (string)$response->getBody()); |
|
| 37 | 37 | self::assertSame(300, $response->getStatusCode()); |
| 38 | 38 | self::assertSame('application/json', $response->getHeaderLine('Content-Type')); |
| 39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | public function testHtml(): void |
| 42 | 42 | { |
| 43 | 43 | $response = $this->getWrapper()->html('hello world'); |
| 44 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 44 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 45 | 45 | self::assertSame(200, $response->getStatusCode()); |
| 46 | 46 | $response->getHeader('Content-Type'); |
| 47 | 47 | self::assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type')); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $response = $this->getWrapper()->attachment(__FILE__); |
| 53 | 53 | |
| 54 | 54 | self::assertSame(200, $response->getStatusCode()); |
| 55 | - self::assertStringEqualsFile(__FILE__, (string) $response->getBody()); |
|
| 55 | + self::assertStringEqualsFile(__FILE__, (string)$response->getBody()); |
|
| 56 | 56 | self::assertSame(\filesize(__FILE__), $response->getBody()->getSize()); |
| 57 | 57 | self::assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $response = $this->getWrapper()->attachment(\fopen(__FILE__, 'r'), 'file.php'); |
| 63 | 63 | |
| 64 | 64 | self::assertSame(200, $response->getStatusCode()); |
| 65 | - self::assertStringEqualsFile(__FILE__, (string) $response->getBody()); |
|
| 65 | + self::assertStringEqualsFile(__FILE__, (string)$response->getBody()); |
|
| 66 | 66 | self::assertSame(\filesize(__FILE__), $response->getBody()->getSize()); |
| 67 | 67 | self::assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); |
| 68 | 68 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $response = $this->getWrapper()->attachment(Stream::create(\fopen(__FILE__, 'r')), 'file.php'); |
| 73 | 73 | |
| 74 | 74 | self::assertSame(200, $response->getStatusCode()); |
| 75 | - self::assertStringEqualsFile(__FILE__, (string) $response->getBody()); |
|
| 75 | + self::assertStringEqualsFile(__FILE__, (string)$response->getBody()); |
|
| 76 | 76 | self::assertSame(\filesize(__FILE__), $response->getBody()->getSize()); |
| 77 | 77 | self::assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); |
| 78 | 78 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | |
| 87 | 87 | self::assertSame(200, $response->getStatusCode()); |
| 88 | - self::assertStringEqualsFile(__FILE__, (string) $response->getBody()); |
|
| 88 | + self::assertStringEqualsFile(__FILE__, (string)$response->getBody()); |
|
| 89 | 89 | self::assertSame(\filesize(__FILE__), $response->getBody()->getSize()); |
| 90 | 90 | self::assertSame('application/octet-stream', $response->getHeaderLine('Content-Type')); |
| 91 | 91 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ]); |
| 86 | 86 | |
| 87 | 87 | self::assertCount(0, $header->getAll()); |
| 88 | - self::assertSame('', (string) $header); |
|
| 88 | + self::assertSame('', (string)$header); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function testHeaderSanitize(): void |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | public function testDuplicatedItems(): void |
| 122 | 122 | { |
| 123 | 123 | $header = AcceptHeader::fromString('*/*;q=0.9,text/html,*/*'); |
| 124 | - self::assertSame('text/html, */*', (string) $header); |
|
| 124 | + self::assertSame('text/html, */*', (string)$header); |
|
| 125 | 125 | |
| 126 | 126 | $header = AcceptHeader::fromString('text/html;q=0.4,*/*;q=0.9,text/html;q=0.6'); |
| 127 | - self::assertSame('*/*; q=0.9, text/html; q=0.6', (string) $header); |
|
| 127 | + self::assertSame('*/*; q=0.9, text/html; q=0.6', (string)$header); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public function testAccessor(): void |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | self::assertTrue($acceptHeader->has('tExt/css ')); |
| 134 | 134 | self::assertFalse($acceptHeader->has('tExt/javascript')); |
| 135 | 135 | |
| 136 | - self::assertSame('text/css; q=0.3', (string) $acceptHeader->get('text/css')); |
|
| 137 | - self::assertSame('text/html; q=0.3', (string) $acceptHeader->get('text/html')); |
|
| 136 | + self::assertSame('text/css; q=0.3', (string)$acceptHeader->get('text/css')); |
|
| 137 | + self::assertSame('text/html; q=0.3', (string)$acceptHeader->get('text/html')); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | #[DataProvider('addAndSortProvider')] |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $headers = $acceptHeader->getAll(); |
| 147 | 147 | self::assertCount(\count($expected), $headers); |
| 148 | 148 | |
| 149 | - foreach ($expected as $i => $value) { |
|
| 149 | + foreach ($expected as $i => $value){ |
|
| 150 | 150 | self::assertSame($value, $headers[$i]->getValue()); |
| 151 | 151 | } |
| 152 | 152 | } |
@@ -159,8 +159,8 @@ discard block |
||
| 159 | 159 | $headers = $acceptHeader->getAll(); |
| 160 | 160 | self::assertCount(\count($expected), $headers); |
| 161 | 161 | |
| 162 | - foreach ($expected as $i => $value) { |
|
| 163 | - self::assertSame($value, (string) $headers[$i]); |
|
| 162 | + foreach ($expected as $i => $value){ |
|
| 163 | + self::assertSame($value, (string)$headers[$i]); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -146,7 +146,8 @@ discard block |
||
| 146 | 146 | $headers = $acceptHeader->getAll(); |
| 147 | 147 | self::assertCount(\count($expected), $headers); |
| 148 | 148 | |
| 149 | - foreach ($expected as $i => $value) { |
|
| 149 | + foreach ($expected as $i => $value) |
|
| 150 | + { |
|
| 150 | 151 | self::assertSame($value, $headers[$i]->getValue()); |
| 151 | 152 | } |
| 152 | 153 | } |
@@ -159,7 +160,8 @@ discard block |
||
| 159 | 160 | $headers = $acceptHeader->getAll(); |
| 160 | 161 | self::assertCount(\count($expected), $headers); |
| 161 | 162 | |
| 162 | - foreach ($expected as $i => $value) { |
|
| 163 | + foreach ($expected as $i => $value) |
|
| 164 | + { |
|
| 163 | 165 | self::assertSame($value, (string) $headers[$i]); |
| 164 | 166 | } |
| 165 | 167 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $core->setHandler(static fn(): string => 'hello world'); |
| 43 | 43 | |
| 44 | 44 | $response = $core->handle(new ServerRequest('GET', '')); |
| 45 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 45 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function testNoHandler(): void |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $core = $this->getCore(); |
| 53 | 53 | |
| 54 | 54 | $response = $core->handle(new ServerRequest('GET', '')); |
| 55 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 55 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function testHandlerInterface(): void |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | $response = $core->handle(new ServerRequest('GET', '')); |
| 66 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 66 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public function testDefaultHeaders(): void |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $core = $this->getCore(); |
| 83 | 83 | |
| 84 | - $core->setHandler(static function ($req, $resp) { |
|
| 84 | + $core->setHandler(static function ($req, $resp){ |
|
| 85 | 85 | echo 'hello!'; |
| 86 | 86 | |
| 87 | 87 | return $resp->withAddedHeader('hello', 'value'); |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | $response = $core->handle(new ServerRequest('GET', '')); |
| 91 | 91 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 92 | 92 | self::assertSame(['value'], $response->getHeader('hello')); |
| 93 | - self::assertSame('hello!', (string) $response->getBody()); |
|
| 93 | + self::assertSame('hello!', (string)$response->getBody()); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | public function testOutputAndWrite(): void |
| 97 | 97 | { |
| 98 | 98 | $core = $this->getCore(); |
| 99 | 99 | |
| 100 | - $core->setHandler(static function ($req, $resp) { |
|
| 100 | + $core->setHandler(static function ($req, $resp){ |
|
| 101 | 101 | echo 'hello!'; |
| 102 | 102 | $resp->getBody()->write('world '); |
| 103 | 103 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $response = $core->handle(new ServerRequest('GET', '')); |
| 108 | 108 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 109 | 109 | self::assertSame(['value'], $response->getHeader('hello')); |
| 110 | - self::assertSame('world hello!', (string) $response->getBody()); |
|
| 110 | + self::assertSame('world hello!', (string)$response->getBody()); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public function testNestedOutput(): void |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | self::assertSame(1, \ob_get_level()); |
| 128 | 128 | $response = $core->handle(new ServerRequest('GET', '')); |
| 129 | 129 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 130 | - self::assertSame('world hello!', (string) $response->getBody()); |
|
| 130 | + self::assertSame('world hello!', (string)$response->getBody()); |
|
| 131 | 131 | self::assertSame(1, \ob_get_level()); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $response = $core->handle(new ServerRequest('GET', '')); |
| 169 | 169 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 170 | 170 | self::assertSame(['Value*'], $response->getHeader('header')); |
| 171 | - self::assertSame('hello?', (string) $response->getBody()); |
|
| 171 | + self::assertSame('hello?', (string)$response->getBody()); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function testMiddlewareTrait(): void |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $response = $core->handle(new ServerRequest('GET', '')); |
| 184 | 184 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 185 | 185 | self::assertSame(['Value+', 'Value*'], $response->getHeader('header')); |
| 186 | - self::assertSame('hello?', (string) $response->getBody()); |
|
| 186 | + self::assertSame('hello?', (string)$response->getBody()); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | public function testMiddlewareTraitReversed(): void |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $response = $core->handle(new ServerRequest('GET', '')); |
| 199 | 199 | self::assertSame(['text/html; charset=UTF-8'], $response->getHeader('Content-Type')); |
| 200 | 200 | self::assertSame(['Value*', 'Value+'], $response->getHeader('header')); |
| 201 | - self::assertSame('hello?', (string) $response->getBody()); |
|
| 201 | + self::assertSame('hello?', (string)$response->getBody()); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | public function testPassException(): void |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $dispatcher |
| 225 | 225 | ->expects(self::exactly(2)) |
| 226 | 226 | ->method('dispatch') |
| 227 | - ->with($this->callback(static fn(RequestReceived|RequestHandled $event): bool => true)); |
|
| 227 | + ->with($this->callback(static fn(RequestReceived | RequestHandled $event): bool => true)); |
|
| 228 | 228 | $this->container->bind(EventDispatcherInterface::class, $dispatcher); |
| 229 | 229 | |
| 230 | 230 | $core = $this->getCore(); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | $core->setHandler(static fn(): string => 'hello world'); |
| 233 | 233 | |
| 234 | 234 | $response = $core->handle($request); |
| 235 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 235 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public function testPassingTracerIntoScope(): void |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | ->andReturn(new NullTracer($this->container)); |
| 258 | 258 | |
| 259 | 259 | $response = $http->handle($request); |
| 260 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 260 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | public function testTraceAttributesAreSet(): void |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | TraceKind::SERVER, |
| 282 | 282 | ) |
| 283 | 283 | ->willReturnCallback( |
| 284 | - function ($name, $callback, $attributes, $scoped, $traceKind) { |
|
| 284 | + function ($name, $callback, $attributes, $scoped, $traceKind){ |
|
| 285 | 285 | self::assertSame($attributes, [ |
| 286 | 286 | 'http.method' => 'GET', |
| 287 | 287 | 'http.url' => 'http://example.org/path', |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $http->setHandler(static fn(): string => 'hello world'); |
| 315 | 315 | |
| 316 | 316 | $response = $http->handle($request); |
| 317 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 317 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | public function testTraceContextIsAppliedToResponse(): void |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | ->andReturn(['baz' => 'quux']); |
| 355 | 355 | |
| 356 | 356 | $response = $http->handle($request); |
| 357 | - self::assertSame('hello world', (string) $response->getBody()); |
|
| 357 | + self::assertSame('hello world', (string)$response->getBody()); |
|
| 358 | 358 | self::assertSame(['quux'], $response->getHeader('baz')); |
| 359 | 359 | } |
| 360 | 360 | |
@@ -81,7 +81,8 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $core = $this->getCore(); |
| 83 | 83 | |
| 84 | - $core->setHandler(static function ($req, $resp) { |
|
| 84 | + $core->setHandler(static function ($req, $resp) |
|
| 85 | + { |
|
| 85 | 86 | echo 'hello!'; |
| 86 | 87 | |
| 87 | 88 | return $resp->withAddedHeader('hello', 'value'); |
@@ -97,7 +98,8 @@ discard block |
||
| 97 | 98 | { |
| 98 | 99 | $core = $this->getCore(); |
| 99 | 100 | |
| 100 | - $core->setHandler(static function ($req, $resp) { |
|
| 101 | + $core->setHandler(static function ($req, $resp) |
|
| 102 | + { |
|
| 101 | 103 | echo 'hello!'; |
| 102 | 104 | $resp->getBody()->write('world '); |
| 103 | 105 | |
@@ -281,7 +283,8 @@ discard block |
||
| 281 | 283 | TraceKind::SERVER, |
| 282 | 284 | ) |
| 283 | 285 | ->willReturnCallback( |
| 284 | - function ($name, $callback, $attributes, $scoped, $traceKind) { |
|
| 286 | + function ($name, $callback, $attributes, $scoped, $traceKind) |
|
| 287 | + { |
|
| 285 | 288 | self::assertSame($attributes, [ |
| 286 | 289 | 'http.method' => 'GET', |
| 287 | 290 | 'http.url' => 'http://example.org/path', |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | #[Proxy] private readonly ContainerInterface $container, |
| 124 | 124 | /** @invisible */ |
| 125 | 125 | HttpConfig $config = new HttpConfig(), |
| 126 | - ) { |
|
| 126 | + ){ |
|
| 127 | 127 | $this->bagAssociations = \array_merge($this->bagAssociations, $config->getInputBags()); |
| 128 | 128 | } |
| 129 | 129 | |
@@ -134,10 +134,10 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $input = clone $this; |
| 136 | 136 | |
| 137 | - if ($add) { |
|
| 138 | - $input->prefix .= '.' . $prefix; |
|
| 137 | + if ($add){ |
|
| 138 | + $input->prefix .= '.'.$prefix; |
|
| 139 | 139 | $input->prefix = \trim($input->prefix, '.'); |
| 140 | - } else { |
|
| 140 | + }else{ |
|
| 141 | 141 | $input->prefix = $prefix; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | return match (true) { |
| 155 | 155 | empty($path) => '/', |
| 156 | - $path[0] !== '/' => '/' . $path, |
|
| 156 | + $path[0] !== '/' => '/'.$path, |
|
| 157 | 157 | default => $path, |
| 158 | 158 | }; |
| 159 | 159 | } |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | */ |
| 174 | 174 | public function request(): Request |
| 175 | 175 | { |
| 176 | - try { |
|
| 176 | + try{ |
|
| 177 | 177 | $request = $this->container->get(Request::class); |
| 178 | - } catch (ContainerExceptionInterface $e) { |
|
| 178 | + }catch (ContainerExceptionInterface $e){ |
|
| 179 | 179 | $scope = \implode('.', \array_reverse(Introspector::scopeNames($this->container))); |
| 180 | 180 | throw new ScopeException( |
| 181 | 181 | "Unable to get `ServerRequestInterface` in the `$scope` container scope", |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Flushing input state |
| 188 | - if ($this->request !== $request) { |
|
| 188 | + if ($this->request !== $request){ |
|
| 189 | 189 | $this->bags = []; |
| 190 | 190 | $this->request = $request; |
| 191 | 191 | } |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function bearerToken(): ?string |
| 200 | 200 | { |
| 201 | - $header = (string) $this->header('Authorization', ''); |
|
| 201 | + $header = (string)$this->header('Authorization', ''); |
|
| 202 | 202 | |
| 203 | 203 | $position = \strrpos($header, 'Bearer '); |
| 204 | 204 | |
| 205 | - if ($position !== false) { |
|
| 205 | + if ($position !== false){ |
|
| 206 | 206 | $header = \substr($header, $position + 7); |
| 207 | 207 | |
| 208 | 208 | return \str_contains($header, ',') |
@@ -256,16 +256,16 @@ discard block |
||
| 256 | 256 | public function isJsonExpected(bool $softMatch = false): bool |
| 257 | 257 | { |
| 258 | 258 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
| 259 | - foreach ($this->jsonTypes as $jsonType) { |
|
| 260 | - if ($acceptHeader->has($jsonType)) { |
|
| 259 | + foreach ($this->jsonTypes as $jsonType){ |
|
| 260 | + if ($acceptHeader->has($jsonType)){ |
|
| 261 | 261 | return true; |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - if ($softMatch) { |
|
| 266 | - foreach ($acceptHeader->getAll() as $item) { |
|
| 267 | - $itemValue = \strtolower((string) $item->getValue()); |
|
| 268 | - if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) { |
|
| 265 | + if ($softMatch){ |
|
| 266 | + foreach ($acceptHeader->getAll() as $item){ |
|
| 267 | + $itemValue = \strtolower((string)$item->getValue()); |
|
| 268 | + if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')){ |
|
| 269 | 269 | return true; |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -304,20 +304,20 @@ discard block |
||
| 304 | 304 | // ensure proper request association |
| 305 | 305 | $this->request(); |
| 306 | 306 | |
| 307 | - if (isset($this->bags[$name])) { |
|
| 307 | + if (isset($this->bags[$name])){ |
|
| 308 | 308 | return $this->bags[$name]; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $definition = $this->findBagDefinition($name); |
| 312 | - if (!$definition) { |
|
| 312 | + if (!$definition){ |
|
| 313 | 313 | throw new InputException(\sprintf("Undefined input bag '%s'", $name)); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $class = $definition['class']; |
| 317 | 317 | $data = \call_user_func([$this->request(), $definition['source']]); |
| 318 | 318 | |
| 319 | - if (!\is_array($data)) { |
|
| 320 | - $data = (array) $data; |
|
| 319 | + if (!\is_array($data)){ |
|
| 320 | + $data = (array)$data; |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | return $this->bags[$name] = new $class($data, $this->prefix); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | public function hasBag(string $name): bool |
| 327 | 327 | { |
| 328 | - if (isset($this->bags[$name])) { |
|
| 328 | + if (isset($this->bags[$name])){ |
|
| 329 | 329 | return true; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -363,12 +363,12 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | private function findBagDefinition(string $name): ?array |
| 365 | 365 | { |
| 366 | - if (isset($this->bagAssociations[$name])) { |
|
| 366 | + if (isset($this->bagAssociations[$name])){ |
|
| 367 | 367 | return $this->bagAssociations[$name]; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | - foreach ($this->bagAssociations as $bag) { |
|
| 371 | - if (isset($bag['alias']) && $bag['alias'] === $name) { |
|
| 370 | + foreach ($this->bagAssociations as $bag){ |
|
| 371 | + if (isset($bag['alias']) && $bag['alias'] === $name){ |
|
| 372 | 372 | return $bag; |
| 373 | 373 | } |
| 374 | 374 | } |
@@ -134,10 +134,13 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $input = clone $this; |
| 136 | 136 | |
| 137 | - if ($add) { |
|
| 137 | + if ($add) |
|
| 138 | + { |
|
| 138 | 139 | $input->prefix .= '.' . $prefix; |
| 139 | 140 | $input->prefix = \trim($input->prefix, '.'); |
| 140 | - } else { |
|
| 141 | + } |
|
| 142 | + else |
|
| 143 | + { |
|
| 141 | 144 | $input->prefix = $prefix; |
| 142 | 145 | } |
| 143 | 146 | |
@@ -173,9 +176,12 @@ discard block |
||
| 173 | 176 | */ |
| 174 | 177 | public function request(): Request |
| 175 | 178 | { |
| 176 | - try { |
|
| 179 | + try |
|
| 180 | + { |
|
| 177 | 181 | $request = $this->container->get(Request::class); |
| 178 | - } catch (ContainerExceptionInterface $e) { |
|
| 182 | + } |
|
| 183 | + catch (ContainerExceptionInterface $e) |
|
| 184 | + { |
|
| 179 | 185 | $scope = \implode('.', \array_reverse(Introspector::scopeNames($this->container))); |
| 180 | 186 | throw new ScopeException( |
| 181 | 187 | "Unable to get `ServerRequestInterface` in the `$scope` container scope", |
@@ -185,7 +191,8 @@ discard block |
||
| 185 | 191 | } |
| 186 | 192 | |
| 187 | 193 | // Flushing input state |
| 188 | - if ($this->request !== $request) { |
|
| 194 | + if ($this->request !== $request) |
|
| 195 | + { |
|
| 189 | 196 | $this->bags = []; |
| 190 | 197 | $this->request = $request; |
| 191 | 198 | } |
@@ -202,7 +209,8 @@ discard block |
||
| 202 | 209 | |
| 203 | 210 | $position = \strrpos($header, 'Bearer '); |
| 204 | 211 | |
| 205 | - if ($position !== false) { |
|
| 212 | + if ($position !== false) |
|
| 213 | + { |
|
| 206 | 214 | $header = \substr($header, $position + 7); |
| 207 | 215 | |
| 208 | 216 | return \str_contains($header, ',') |
@@ -256,16 +264,21 @@ discard block |
||
| 256 | 264 | public function isJsonExpected(bool $softMatch = false): bool |
| 257 | 265 | { |
| 258 | 266 | $acceptHeader = AcceptHeader::fromString($this->request()->getHeaderLine('Accept')); |
| 259 | - foreach ($this->jsonTypes as $jsonType) { |
|
| 260 | - if ($acceptHeader->has($jsonType)) { |
|
| 267 | + foreach ($this->jsonTypes as $jsonType) |
|
| 268 | + { |
|
| 269 | + if ($acceptHeader->has($jsonType)) |
|
| 270 | + { |
|
| 261 | 271 | return true; |
| 262 | 272 | } |
| 263 | 273 | } |
| 264 | 274 | |
| 265 | - if ($softMatch) { |
|
| 266 | - foreach ($acceptHeader->getAll() as $item) { |
|
| 275 | + if ($softMatch) |
|
| 276 | + { |
|
| 277 | + foreach ($acceptHeader->getAll() as $item) |
|
| 278 | + { |
|
| 267 | 279 | $itemValue = \strtolower((string) $item->getValue()); |
| 268 | - if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) { |
|
| 280 | + if (\str_ends_with($itemValue, '/json') || \str_ends_with($itemValue, '+json')) |
|
| 281 | + { |
|
| 269 | 282 | return true; |
| 270 | 283 | } |
| 271 | 284 | } |
@@ -304,19 +317,22 @@ discard block |
||
| 304 | 317 | // ensure proper request association |
| 305 | 318 | $this->request(); |
| 306 | 319 | |
| 307 | - if (isset($this->bags[$name])) { |
|
| 320 | + if (isset($this->bags[$name])) |
|
| 321 | + { |
|
| 308 | 322 | return $this->bags[$name]; |
| 309 | 323 | } |
| 310 | 324 | |
| 311 | 325 | $definition = $this->findBagDefinition($name); |
| 312 | - if (!$definition) { |
|
| 326 | + if (!$definition) |
|
| 327 | + { |
|
| 313 | 328 | throw new InputException(\sprintf("Undefined input bag '%s'", $name)); |
| 314 | 329 | } |
| 315 | 330 | |
| 316 | 331 | $class = $definition['class']; |
| 317 | 332 | $data = \call_user_func([$this->request(), $definition['source']]); |
| 318 | 333 | |
| 319 | - if (!\is_array($data)) { |
|
| 334 | + if (!\is_array($data)) |
|
| 335 | + { |
|
| 320 | 336 | $data = (array) $data; |
| 321 | 337 | } |
| 322 | 338 | |
@@ -325,7 +341,8 @@ discard block |
||
| 325 | 341 | |
| 326 | 342 | public function hasBag(string $name): bool |
| 327 | 343 | { |
| 328 | - if (isset($this->bags[$name])) { |
|
| 344 | + if (isset($this->bags[$name])) |
|
| 345 | + { |
|
| 329 | 346 | return true; |
| 330 | 347 | } |
| 331 | 348 | |
@@ -363,12 +380,15 @@ discard block |
||
| 363 | 380 | */ |
| 364 | 381 | private function findBagDefinition(string $name): ?array |
| 365 | 382 | { |
| 366 | - if (isset($this->bagAssociations[$name])) { |
|
| 383 | + if (isset($this->bagAssociations[$name])) |
|
| 384 | + { |
|
| 367 | 385 | return $this->bagAssociations[$name]; |
| 368 | 386 | } |
| 369 | 387 | |
| 370 | - foreach ($this->bagAssociations as $bag) { |
|
| 371 | - if (isset($bag['alias']) && $bag['alias'] === $name) { |
|
| 388 | + foreach ($this->bagAssociations as $bag) |
|
| 389 | + { |
|
| 390 | + if (isset($bag['alias']) && $bag['alias'] === $name) |
|
| 391 | + { |
|
| 372 | 392 | return $bag; |
| 373 | 393 | } |
| 374 | 394 | } |
@@ -48,19 +48,19 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | protected function mapDirectories(array $directories): array |
| 50 | 50 | { |
| 51 | - if (!isset($directories['root'])) { |
|
| 51 | + if (!isset($directories['root'])){ |
|
| 52 | 52 | throw new Boot\Exception\BootException('Missing required directory `root`.'); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (!isset($directories['app'])) { |
|
| 56 | - $directories['app'] = $directories['root'] . '/'; |
|
| 55 | + if (!isset($directories['app'])){ |
|
| 56 | + $directories['app'] = $directories['root'].'/'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return \array_merge([ |
| 60 | - 'vendor' => $directories['root'] . '/vendor/', |
|
| 61 | - 'runtime' => $directories['root'] . '/runtime/', |
|
| 62 | - 'config' => $directories['app'] . '/config/', |
|
| 63 | - 'resources' => $directories['root'] . '/resources/', |
|
| 60 | + 'vendor' => $directories['root'].'/vendor/', |
|
| 61 | + 'runtime' => $directories['root'].'/runtime/', |
|
| 62 | + 'config' => $directories['app'].'/config/', |
|
| 63 | + 'resources' => $directories['root'].'/resources/', |
|
| 64 | 64 | ], $directories); |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -16,18 +16,18 @@ |
||
| 16 | 16 | { |
| 17 | 17 | parent::tearDown(); |
| 18 | 18 | |
| 19 | - if ($this->className) { |
|
| 19 | + if ($this->className){ |
|
| 20 | 20 | $this->deleteDeclaration($this->className); |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function deleteDeclaration(string $class): void |
| 25 | 25 | { |
| 26 | - if (\class_exists($class)) { |
|
| 27 | - try { |
|
| 26 | + if (\class_exists($class)){ |
|
| 27 | + try{ |
|
| 28 | 28 | $reflection = new \ReflectionClass($class); |
| 29 | 29 | $this->files()->delete($reflection->getFileName()); |
| 30 | - } catch (\Throwable $exception) { |
|
| 30 | + }catch (\Throwable $exception){ |
|
| 31 | 31 | \var_dump($exception->getMessage()); |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -16,18 +16,23 @@ |
||
| 16 | 16 | { |
| 17 | 17 | parent::tearDown(); |
| 18 | 18 | |
| 19 | - if ($this->className) { |
|
| 19 | + if ($this->className) |
|
| 20 | + { |
|
| 20 | 21 | $this->deleteDeclaration($this->className); |
| 21 | 22 | } |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | 25 | protected function deleteDeclaration(string $class): void |
| 25 | 26 | { |
| 26 | - if (\class_exists($class)) { |
|
| 27 | - try { |
|
| 27 | + if (\class_exists($class)) |
|
| 28 | + { |
|
| 29 | + try |
|
| 30 | + { |
|
| 28 | 31 | $reflection = new \ReflectionClass($class); |
| 29 | 32 | $this->files()->delete($reflection->getFileName()); |
| 30 | - } catch (\Throwable $exception) { |
|
| 33 | + } |
|
| 34 | + catch (\Throwable $exception) |
|
| 35 | + { |
|
| 31 | 36 | \var_dump($exception->getMessage()); |
| 32 | 37 | } |
| 33 | 38 | } |
@@ -127,17 +127,17 @@ discard block |
||
| 127 | 127 | ]; |
| 128 | 128 | |
| 129 | 129 | $reflectionMethods = []; |
| 130 | - foreach ($reflection->getMethods() as $method) { |
|
| 131 | - if ($method->getDeclaringClass()->name !== $reflection->name) { |
|
| 130 | + foreach ($reflection->getMethods() as $method){ |
|
| 131 | + if ($method->getDeclaringClass()->name !== $reflection->name){ |
|
| 132 | 132 | continue; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $reflectionMethods[$method->name] = $method; |
| 136 | 136 | self::assertArrayHasKey($method->name, $methods); |
| 137 | 137 | |
| 138 | - if (!$method->hasReturnType()) { |
|
| 138 | + if (!$method->hasReturnType()){ |
|
| 139 | 139 | self::assertNull($methods[$method->name]['hint']); |
| 140 | - } else { |
|
| 140 | + }else{ |
|
| 141 | 141 | self::assertEquals($methods[$method->name]['hint'], $method->getReturnType()->getName()); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | ]; |
| 178 | 178 | |
| 179 | 179 | $reflectionMethods = []; |
| 180 | - foreach ($reflection->getMethods() as $method) { |
|
| 181 | - if ($method->getDeclaringClass()->name !== $reflection->name) { |
|
| 180 | + foreach ($reflection->getMethods() as $method){ |
|
| 181 | + if ($method->getDeclaringClass()->name !== $reflection->name){ |
|
| 182 | 182 | continue; |
| 183 | 183 | } |
| 184 | 184 | $reflectionMethods[$method->name] = $method; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | \clearstatcache(); |
| 265 | 265 | |
| 266 | - $filename = $this->app->directory('config') . "$name.php"; |
|
| 266 | + $filename = $this->app->directory('config')."$name.php"; |
|
| 267 | 267 | self::assertFileExists($filename); |
| 268 | 268 | |
| 269 | 269 | return $filename; |