@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct( |
22 | 22 | /** @internal */ |
23 | 23 | protected ContainerInterface $container, |
24 | - ) {} |
|
24 | + ){} |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @psalm-assert class-string $controller |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | ); |
38 | 38 | $path = $context->getTarget()->getPath(); |
39 | 39 | |
40 | - if ($method instanceof \ReflectionFunction) { |
|
40 | + if ($method instanceof \ReflectionFunction){ |
|
41 | 41 | return $method->invokeArgs( |
42 | 42 | $this->resolveArguments($method, $context), |
43 | 43 | ); |
44 | 44 | } |
45 | 45 | |
46 | - if (!$method instanceof \ReflectionMethod) { |
|
46 | + if (!$method instanceof \ReflectionMethod){ |
|
47 | 47 | throw new TargetCallException("Action not found for target `{$context->getTarget()}`."); |
48 | 48 | } |
49 | 49 |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | public function __construct( |
22 | 22 | /** @internal */ |
23 | 23 | protected ContainerInterface $container, |
24 | - ) {} |
|
24 | + ) { |
|
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * @psalm-assert class-string $controller |
@@ -37,13 +38,15 @@ discard block |
||
37 | 38 | ); |
38 | 39 | $path = $context->getTarget()->getPath(); |
39 | 40 | |
40 | - if ($method instanceof \ReflectionFunction) { |
|
41 | + if ($method instanceof \ReflectionFunction) |
|
42 | + { |
|
41 | 43 | return $method->invokeArgs( |
42 | 44 | $this->resolveArguments($method, $context), |
43 | 45 | ); |
44 | 46 | } |
45 | 47 | |
46 | - if (!$method instanceof \ReflectionMethod) { |
|
48 | + if (!$method instanceof \ReflectionMethod) |
|
49 | + { |
|
47 | 50 | throw new TargetCallException("Action not found for target `{$context->getTarget()}`."); |
48 | 51 | } |
49 | 52 |
@@ -4,6 +4,6 @@ |
||
4 | 4 | |
5 | 5 | namespace Spiral\Interceptors\Exception; |
6 | 6 | |
7 | -class InterceptorException extends \RuntimeException {} |
|
7 | +class InterceptorException extends \RuntimeException{} |
|
8 | 8 | |
9 | 9 | \class_alias(InterceptorException::class, \Spiral\Core\Exception\InterceptorException::class); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public static function emptyItemProvider(): iterable |
15 | 15 | { |
16 | 16 | $values = ['', ' ']; |
17 | - foreach ($values as $value) { |
|
17 | + foreach ($values as $value){ |
|
18 | 18 | yield from [ |
19 | 19 | [AcceptHeaderItem::fromString($value)], |
20 | 20 | [new AcceptHeaderItem($value)], |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | public static function qualityBoundariesProvider(): iterable |
35 | 35 | { |
36 | 36 | $qualities = [-1, 0, 0.5, 1, 2]; |
37 | - foreach ($qualities as $quality) { |
|
37 | + foreach ($qualities as $quality){ |
|
38 | 38 | yield from [ |
39 | 39 | [$quality, AcceptHeaderItem::fromString("*;q=$quality")], |
40 | 40 | [$quality, AcceptHeaderItem::fromString("*;Q=$quality")], |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | ], |
62 | 62 | ]; |
63 | 63 | |
64 | - foreach ($set as $params) { |
|
64 | + foreach ($set as $params){ |
|
65 | 65 | $formattedParams = []; |
66 | - foreach ($params['passed'] as $k => $v) { |
|
66 | + foreach ($params['passed'] as $k => $v){ |
|
67 | 67 | $formattedParams[] = "$k=$v"; |
68 | 68 | } |
69 | 69 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | public function testEmptyItem(AcceptHeaderItem $item): void |
117 | 117 | { |
118 | 118 | self::assertEmpty($item->getValue()); |
119 | - self::assertSame('', (string) $item); |
|
119 | + self::assertSame('', (string)$item); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | #[DataProvider('valueProvider')] |
@@ -133,17 +133,17 @@ discard block |
||
133 | 133 | |
134 | 134 | $acceptHeader = new AcceptHeader([$item]); |
135 | 135 | self::assertCount(1, $acceptHeader->getAll()); |
136 | - self::assertSame($value, (string) $acceptHeader->getAll()[0]); |
|
136 | + self::assertSame($value, (string)$acceptHeader->getAll()[0]); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | #[DataProvider('qualityBoundariesProvider')] |
140 | 140 | public function testItemQualityBoundaries(float $quality, AcceptHeaderItem $item): void |
141 | 141 | { |
142 | - if ($quality > 1) { |
|
142 | + if ($quality > 1){ |
|
143 | 143 | self::assertEqualsWithDelta(1.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
144 | 144 | } |
145 | 145 | |
146 | - if ($quality < 0) { |
|
146 | + if ($quality < 0){ |
|
147 | 147 | self::assertEqualsWithDelta(0.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
148 | 148 | } |
149 | 149 | |
@@ -160,6 +160,6 @@ discard block |
||
160 | 160 | #[DataProvider('itemProvider')] |
161 | 161 | public function testItem(string $expected, AcceptHeaderItem $item): void |
162 | 162 | { |
163 | - self::assertSame($expected, (string) $item); |
|
163 | + self::assertSame($expected, (string)$item); |
|
164 | 164 | } |
165 | 165 | } |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | public static function emptyItemProvider(): iterable |
15 | 15 | { |
16 | 16 | $values = ['', ' ']; |
17 | - foreach ($values as $value) { |
|
17 | + foreach ($values as $value) |
|
18 | + { |
|
18 | 19 | yield from [ |
19 | 20 | [AcceptHeaderItem::fromString($value)], |
20 | 21 | [new AcceptHeaderItem($value)], |
@@ -34,7 +35,8 @@ discard block |
||
34 | 35 | public static function qualityBoundariesProvider(): iterable |
35 | 36 | { |
36 | 37 | $qualities = [-1, 0, 0.5, 1, 2]; |
37 | - foreach ($qualities as $quality) { |
|
38 | + foreach ($qualities as $quality) |
|
39 | + { |
|
38 | 40 | yield from [ |
39 | 41 | [$quality, AcceptHeaderItem::fromString("*;q=$quality")], |
40 | 42 | [$quality, AcceptHeaderItem::fromString("*;Q=$quality")], |
@@ -61,9 +63,11 @@ discard block |
||
61 | 63 | ], |
62 | 64 | ]; |
63 | 65 | |
64 | - foreach ($set as $params) { |
|
66 | + foreach ($set as $params) |
|
67 | + { |
|
65 | 68 | $formattedParams = []; |
66 | - foreach ($params['passed'] as $k => $v) { |
|
69 | + foreach ($params['passed'] as $k => $v) |
|
70 | + { |
|
67 | 71 | $formattedParams[] = "$k=$v"; |
68 | 72 | } |
69 | 73 | |
@@ -139,11 +143,13 @@ discard block |
||
139 | 143 | #[DataProvider('qualityBoundariesProvider')] |
140 | 144 | public function testItemQualityBoundaries(float $quality, AcceptHeaderItem $item): void |
141 | 145 | { |
142 | - if ($quality > 1) { |
|
146 | + if ($quality > 1) |
|
147 | + { |
|
143 | 148 | self::assertEqualsWithDelta(1.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
144 | 149 | } |
145 | 150 | |
146 | - if ($quality < 0) { |
|
151 | + if ($quality < 0) |
|
152 | + { |
|
147 | 153 | self::assertEqualsWithDelta(0.0, $item->getQuality(), PHP_FLOAT_EPSILON); |
148 | 154 | } |
149 | 155 |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | $rValue = 'return-value'; |
98 | 98 | $stream = $this->createStream(self::DEFAULT_SEQUENCE, $rValue); |
99 | 99 | |
100 | - $result = (string) $stream; |
|
100 | + $result = (string)$stream; |
|
101 | 101 | |
102 | - self::assertSame(self::DEFAULT_CONTENT_RESULT . $rValue, $result); |
|
102 | + self::assertSame(self::DEFAULT_CONTENT_RESULT.$rValue, $result); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | public function testToStringWithReturnOnly(): void |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $rValue = 'return-value'; |
108 | 108 | $stream = $this->createStream([], $rValue); |
109 | 109 | |
110 | - $result = (string) $stream; |
|
110 | + $result = (string)$stream; |
|
111 | 111 | |
112 | 112 | self::assertSame($rValue, $result); |
113 | 113 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $stream = $this->createStream(); |
118 | 118 | $stream->close(); |
119 | 119 | |
120 | - self::assertSame('', (string) $stream); |
|
120 | + self::assertSame('', (string)$stream); |
|
121 | 121 | |
122 | 122 | $this->expectException(\RuntimeException::class); |
123 | 123 | $this->expectExceptionMessage('Unable to read stream contents.'); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class Json implements \JsonSerializable |
8 | 8 | { |
9 | - public function __construct(private $data) {} |
|
9 | + public function __construct(private $data){} |
|
10 | 10 | |
11 | 11 | #[\ReturnTypeWillChange] |
12 | 12 | public function jsonSerialize() |
@@ -6,7 +6,9 @@ |
||
6 | 6 | |
7 | 7 | class Json implements \JsonSerializable |
8 | 8 | { |
9 | - public function __construct(private $data) {} |
|
9 | + public function __construct(private $data) |
|
10 | + { |
|
11 | +} |
|
10 | 12 | |
11 | 13 | #[\ReturnTypeWillChange] |
12 | 14 | public function jsonSerialize() |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | class Streamable implements StreamableInterface |
11 | 11 | { |
12 | - public function __construct(private readonly StreamInterface $stream) {} |
|
12 | + public function __construct(private readonly StreamInterface $stream){} |
|
13 | 13 | |
14 | 14 | public function getStream(): StreamInterface |
15 | 15 | { |
@@ -9,7 +9,9 @@ |
||
9 | 9 | |
10 | 10 | class Streamable implements StreamableInterface |
11 | 11 | { |
12 | - public function __construct(private readonly StreamInterface $stream) {} |
|
12 | + public function __construct(private readonly StreamInterface $stream) |
|
13 | + { |
|
14 | +} |
|
13 | 15 | |
14 | 16 | public function getStream(): StreamInterface |
15 | 17 | { |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | private readonly ResponseFactoryInterface $responseFactory, |
26 | 26 | private readonly StreamFactoryInterface $streamFactory, |
27 | 27 | private readonly FilesInterface $files, |
28 | - ) {} |
|
28 | + ){} |
|
29 | 29 | |
30 | 30 | public function create(int $code): ResponseInterface |
31 | 31 | { |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @throws ResponseException |
39 | 39 | */ |
40 | 40 | public function redirect( |
41 | - string|UriInterface $uri, |
|
41 | + string | UriInterface $uri, |
|
42 | 42 | int $code = 302, |
43 | 43 | ): ResponseInterface { |
44 | - return $this->responseFactory->createResponse($code)->withHeader('Location', (string) $uri); |
|
44 | + return $this->responseFactory->createResponse($code)->withHeader('Location', (string)$uri); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | string $name = '', |
67 | 67 | string $mime = 'application/octet-stream', |
68 | 68 | ): ResponseInterface { |
69 | - if (empty($name)) { |
|
70 | - if (!\is_string($filename)) { |
|
69 | + if (empty($name)){ |
|
70 | + if (!\is_string($filename)){ |
|
71 | 71 | throw new ResponseException('Unable to resolve public filename'); |
72 | 72 | } |
73 | 73 | |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | |
79 | 79 | $response = $this->responseFactory->createResponse(); |
80 | 80 | $response = $response->withHeader('Content-Type', $mime); |
81 | - $response = $response->withHeader('Content-Length', (string) $stream->getSize()); |
|
81 | + $response = $response->withHeader('Content-Length', (string)$stream->getSize()); |
|
82 | 82 | $response = $response->withHeader( |
83 | 83 | 'Content-Disposition', |
84 | - 'attachment; filename="' . \addcslashes($name, '"') . '"', |
|
84 | + 'attachment; filename="'.\addcslashes($name, '"').'"', |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | return $response->withBody($stream); |
@@ -25,7 +25,8 @@ discard block |
||
25 | 25 | private readonly ResponseFactoryInterface $responseFactory, |
26 | 26 | private readonly StreamFactoryInterface $streamFactory, |
27 | 27 | private readonly FilesInterface $files, |
28 | - ) {} |
|
28 | + ) { |
|
29 | +} |
|
29 | 30 | |
30 | 31 | public function create(int $code): ResponseInterface |
31 | 32 | { |
@@ -66,8 +67,10 @@ discard block |
||
66 | 67 | string $name = '', |
67 | 68 | string $mime = 'application/octet-stream', |
68 | 69 | ): ResponseInterface { |
69 | - if (empty($name)) { |
|
70 | - if (!\is_string($filename)) { |
|
70 | + if (empty($name)) |
|
71 | + { |
|
72 | + if (!\is_string($filename)) |
|
73 | + { |
|
71 | 74 | throw new ResponseException('Unable to resolve public filename'); |
72 | 75 | } |
73 | 76 |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | |
22 | 22 | public function close(): void |
23 | 23 | { |
24 | - if ($this->stream !== null) { |
|
24 | + if ($this->stream !== null){ |
|
25 | 25 | $this->detach(); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | public function detach() |
30 | 30 | { |
31 | - if ($this->stream === null) { |
|
31 | + if ($this->stream === null){ |
|
32 | 32 | return null; |
33 | 33 | } |
34 | 34 | $this->stream = null; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function rewind(): void |
68 | 68 | { |
69 | - if ($this->stream !== null) { |
|
69 | + if ($this->stream !== null){ |
|
70 | 70 | $this->stream->rewind(); |
71 | 71 | } |
72 | 72 | $this->caret = 0; |
@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | |
91 | 91 | public function read($length): string |
92 | 92 | { |
93 | - if (!$this->readable) { |
|
93 | + if (!$this->readable){ |
|
94 | 94 | throw new \RuntimeException('Cannot read from non-readable stream.'); |
95 | 95 | } |
96 | - if ($this->stream === null) { |
|
96 | + if ($this->stream === null){ |
|
97 | 97 | throw new \RuntimeException('Cannot read from detached stream.'); |
98 | 98 | } |
99 | - do { |
|
100 | - if ($this->started) { |
|
101 | - $read = (string) $this->stream->send(null); |
|
102 | - } else { |
|
99 | + do{ |
|
100 | + if ($this->started){ |
|
101 | + $read = (string)$this->stream->send(null); |
|
102 | + }else{ |
|
103 | 103 | $this->started = true; |
104 | - $read = (string) $this->stream->current(); |
|
104 | + $read = (string)$this->stream->current(); |
|
105 | 105 | } |
106 | - if (!$this->stream->valid()) { |
|
106 | + if (!$this->stream->valid()){ |
|
107 | 107 | $read .= $this->stream->getReturn(); |
108 | 108 | break; |
109 | 109 | } |
110 | - } while ($read === ''); |
|
110 | + }while ($read === ''); |
|
111 | 111 | $this->caret += \strlen($read); |
112 | - if (!$this->stream->valid()) { |
|
112 | + if (!$this->stream->valid()){ |
|
113 | 113 | $this->size = $this->caret; |
114 | 114 | } |
115 | 115 | return $read; |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | |
118 | 118 | public function getContents(): string |
119 | 119 | { |
120 | - if ($this->stream === null) { |
|
120 | + if ($this->stream === null){ |
|
121 | 121 | throw new \RuntimeException('Unable to read stream contents.'); |
122 | 122 | } |
123 | 123 | $content = ''; |
124 | - do { |
|
124 | + do{ |
|
125 | 125 | $content .= $this->read(PHP_INT_MAX); |
126 | - } while ($this->stream->valid()); |
|
126 | + }while ($this->stream->valid()); |
|
127 | 127 | return $content; |
128 | 128 | } |
129 | 129 | |
130 | 130 | public function getMetadata($key = null) |
131 | 131 | { |
132 | - if ($this->stream === null) { |
|
132 | + if ($this->stream === null){ |
|
133 | 133 | return $key ? null : []; |
134 | 134 | } |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'eof' => $this->eof(), |
139 | 139 | ]; |
140 | 140 | |
141 | - if ($key === null) { |
|
141 | + if ($key === null){ |
|
142 | 142 | return $meta; |
143 | 143 | } |
144 | 144 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | public function __toString(): string |
149 | 149 | { |
150 | - try { |
|
150 | + try{ |
|
151 | 151 | return $this->getContents(); |
152 | - } catch (\Exception) { |
|
152 | + }catch (\Exception){ |
|
153 | 153 | return ''; |
154 | 154 | } |
155 | 155 | } |
@@ -21,14 +21,16 @@ discard block |
||
21 | 21 | |
22 | 22 | public function close(): void |
23 | 23 | { |
24 | - if ($this->stream !== null) { |
|
24 | + if ($this->stream !== null) |
|
25 | + { |
|
25 | 26 | $this->detach(); |
26 | 27 | } |
27 | 28 | } |
28 | 29 | |
29 | 30 | public function detach() |
30 | 31 | { |
31 | - if ($this->stream === null) { |
|
32 | + if ($this->stream === null) |
|
33 | + { |
|
32 | 34 | return null; |
33 | 35 | } |
34 | 36 | $this->stream = null; |
@@ -66,7 +68,8 @@ discard block |
||
66 | 68 | |
67 | 69 | public function rewind(): void |
68 | 70 | { |
69 | - if ($this->stream !== null) { |
|
71 | + if ($this->stream !== null) |
|
72 | + { |
|
70 | 73 | $this->stream->rewind(); |
71 | 74 | } |
72 | 75 | $this->caret = 0; |
@@ -90,26 +93,34 @@ discard block |
||
90 | 93 | |
91 | 94 | public function read($length): string |
92 | 95 | { |
93 | - if (!$this->readable) { |
|
96 | + if (!$this->readable) |
|
97 | + { |
|
94 | 98 | throw new \RuntimeException('Cannot read from non-readable stream.'); |
95 | 99 | } |
96 | - if ($this->stream === null) { |
|
100 | + if ($this->stream === null) |
|
101 | + { |
|
97 | 102 | throw new \RuntimeException('Cannot read from detached stream.'); |
98 | 103 | } |
99 | - do { |
|
100 | - if ($this->started) { |
|
104 | + do |
|
105 | + { |
|
106 | + if ($this->started) |
|
107 | + { |
|
101 | 108 | $read = (string) $this->stream->send(null); |
102 | - } else { |
|
109 | + } |
|
110 | + else |
|
111 | + { |
|
103 | 112 | $this->started = true; |
104 | 113 | $read = (string) $this->stream->current(); |
105 | 114 | } |
106 | - if (!$this->stream->valid()) { |
|
115 | + if (!$this->stream->valid()) |
|
116 | + { |
|
107 | 117 | $read .= $this->stream->getReturn(); |
108 | 118 | break; |
109 | 119 | } |
110 | 120 | } while ($read === ''); |
111 | 121 | $this->caret += \strlen($read); |
112 | - if (!$this->stream->valid()) { |
|
122 | + if (!$this->stream->valid()) |
|
123 | + { |
|
113 | 124 | $this->size = $this->caret; |
114 | 125 | } |
115 | 126 | return $read; |
@@ -117,11 +128,13 @@ discard block |
||
117 | 128 | |
118 | 129 | public function getContents(): string |
119 | 130 | { |
120 | - if ($this->stream === null) { |
|
131 | + if ($this->stream === null) |
|
132 | + { |
|
121 | 133 | throw new \RuntimeException('Unable to read stream contents.'); |
122 | 134 | } |
123 | 135 | $content = ''; |
124 | - do { |
|
136 | + do |
|
137 | + { |
|
125 | 138 | $content .= $this->read(PHP_INT_MAX); |
126 | 139 | } while ($this->stream->valid()); |
127 | 140 | return $content; |
@@ -129,7 +142,8 @@ discard block |
||
129 | 142 | |
130 | 143 | public function getMetadata($key = null) |
131 | 144 | { |
132 | - if ($this->stream === null) { |
|
145 | + if ($this->stream === null) |
|
146 | + { |
|
133 | 147 | return $key ? null : []; |
134 | 148 | } |
135 | 149 | |
@@ -138,7 +152,8 @@ discard block |
||
138 | 152 | 'eof' => $this->eof(), |
139 | 153 | ]; |
140 | 154 | |
141 | - if ($key === null) { |
|
155 | + if ($key === null) |
|
156 | + { |
|
142 | 157 | return $meta; |
143 | 158 | } |
144 | 159 | |
@@ -147,9 +162,12 @@ discard block |
||
147 | 162 | |
148 | 163 | public function __toString(): string |
149 | 164 | { |
150 | - try { |
|
165 | + try |
|
166 | + { |
|
151 | 167 | return $this->getContents(); |
152 | - } catch (\Exception) { |
|
168 | + } |
|
169 | + catch (\Exception) |
|
170 | + { |
|
153 | 171 | return ''; |
154 | 172 | } |
155 | 173 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function __construct( |
24 | 24 | callable $callable, |
25 | 25 | private readonly ResponseFactoryInterface $responseFactory, |
26 | - ) { |
|
26 | + ){ |
|
27 | 27 | $this->callable = $callable; |
28 | 28 | } |
29 | 29 | |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | $output = $result = null; |
39 | 39 | |
40 | 40 | $response = $this->responseFactory->createResponse(200); |
41 | - try { |
|
41 | + try{ |
|
42 | 42 | $result = \call_user_func($this->callable, $request, $response); |
43 | - } catch (\Throwable $e) { |
|
43 | + }catch (\Throwable $e){ |
|
44 | 44 | \ob_get_clean(); |
45 | 45 | throw $e; |
46 | - } finally { |
|
47 | - while (\ob_get_level() > $outputLevel + 1) { |
|
48 | - $output = \ob_get_clean() . $output; |
|
46 | + }finally{ |
|
47 | + while (\ob_get_level() > $outputLevel + 1){ |
|
48 | + $output = \ob_get_clean().$output; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | 52 | return $this->wrapResponse( |
53 | 53 | $response, |
54 | 54 | $result, |
55 | - \ob_get_clean() . $output, |
|
55 | + \ob_get_clean().$output, |
|
56 | 56 | ); |
57 | 57 | } |
58 | 58 | |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | */ |
66 | 66 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
67 | 67 | { |
68 | - if ($result instanceof Response) { |
|
69 | - if (!empty($output) && $result->getBody()->isWritable()) { |
|
68 | + if ($result instanceof Response){ |
|
69 | + if (!empty($output) && $result->getBody()->isWritable()){ |
|
70 | 70 | $result->getBody()->write($output); |
71 | 71 | } |
72 | 72 | |
73 | 73 | return $result; |
74 | 74 | } |
75 | 75 | |
76 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
76 | + if (\is_array($result) || $result instanceof \JsonSerializable){ |
|
77 | 77 | $response = $this->writeJson($response, $result); |
78 | - } else { |
|
79 | - $response->getBody()->write((string) $result); |
|
78 | + }else{ |
|
79 | + $response->getBody()->write((string)$result); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | //Always glue buffered output |
@@ -38,13 +38,19 @@ discard block |
||
38 | 38 | $output = $result = null; |
39 | 39 | |
40 | 40 | $response = $this->responseFactory->createResponse(200); |
41 | - try { |
|
41 | + try |
|
42 | + { |
|
42 | 43 | $result = \call_user_func($this->callable, $request, $response); |
43 | - } catch (\Throwable $e) { |
|
44 | + } |
|
45 | + catch (\Throwable $e) |
|
46 | + { |
|
44 | 47 | \ob_get_clean(); |
45 | 48 | throw $e; |
46 | - } finally { |
|
47 | - while (\ob_get_level() > $outputLevel + 1) { |
|
49 | + } |
|
50 | + finally |
|
51 | + { |
|
52 | + while (\ob_get_level() > $outputLevel + 1) |
|
53 | + { |
|
48 | 54 | $output = \ob_get_clean() . $output; |
49 | 55 | } |
50 | 56 | } |
@@ -65,17 +71,22 @@ discard block |
||
65 | 71 | */ |
66 | 72 | private function wrapResponse(Response $response, mixed $result = null, string $output = ''): Response |
67 | 73 | { |
68 | - if ($result instanceof Response) { |
|
69 | - if (!empty($output) && $result->getBody()->isWritable()) { |
|
74 | + if ($result instanceof Response) |
|
75 | + { |
|
76 | + if (!empty($output) && $result->getBody()->isWritable()) |
|
77 | + { |
|
70 | 78 | $result->getBody()->write($output); |
71 | 79 | } |
72 | 80 | |
73 | 81 | return $result; |
74 | 82 | } |
75 | 83 | |
76 | - if (\is_array($result) || $result instanceof \JsonSerializable) { |
|
84 | + if (\is_array($result) || $result instanceof \JsonSerializable) |
|
85 | + { |
|
77 | 86 | $response = $this->writeJson($response, $result); |
78 | - } else { |
|
87 | + } |
|
88 | + else |
|
89 | + { |
|
79 | 90 | $response->getBody()->write((string) $result); |
80 | 91 | } |
81 | 92 |