@@ -22,11 +22,11 @@ discard block |
||
22 | 22 | { |
23 | 23 | $fiber = new Fiber($callable); |
24 | 24 | $value = $fiber->start(); |
25 | - while (!$fiber->isTerminated()) { |
|
26 | - if ($check !== null) { |
|
27 | - try { |
|
25 | + while (!$fiber->isTerminated()){ |
|
26 | + if ($check !== null){ |
|
27 | + try{ |
|
28 | 28 | $value = $check($value); |
29 | - } catch (\Throwable $e) { |
|
29 | + }catch (\Throwable $e){ |
|
30 | 30 | $value = $fiber->throw($e); |
31 | 31 | continue; |
32 | 32 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | /** Values that were suspended by the fiber. */ |
51 | 51 | $suspends = []; |
52 | 52 | $results = []; |
53 | - foreach ($callables as $key => $callable) { |
|
53 | + foreach ($callables as $key => $callable){ |
|
54 | 54 | $fiberGenerators[$key] = (static function () use ($callable) { |
55 | 55 | $fiber = new Fiber($callable); |
56 | 56 | // Get ready |
57 | 57 | yield null; |
58 | 58 | |
59 | 59 | $value = yield $fiber->start(); |
60 | - while (!$fiber->isTerminated()) { |
|
60 | + while (!$fiber->isTerminated()){ |
|
61 | 61 | $value = yield $fiber->resume($value); |
62 | 62 | } |
63 | 63 | return $fiber->getReturn(); |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - while ($fiberGenerators !== []) { |
|
71 | - foreach ($fiberGenerators as $key => $generator) { |
|
72 | - try { |
|
70 | + while ($fiberGenerators !== []){ |
|
71 | + foreach ($fiberGenerators as $key => $generator){ |
|
72 | + try{ |
|
73 | 73 | $suspends[$key] = $generator->send($suspends[$key]); |
74 | - if (!$generator->valid()) { |
|
74 | + if (!$generator->valid()){ |
|
75 | 75 | $results[$key] = $generator->getReturn(); |
76 | 76 | unset($fiberGenerators[$key]); |
77 | 77 | } |
78 | - } catch (\Throwable $e) { |
|
78 | + }catch (\Throwable $e){ |
|
79 | 79 | unset($fiberGenerators[$key]); |
80 | 80 | $results[$key] = $e; |
81 | 81 | } |
@@ -22,11 +22,16 @@ discard block |
||
22 | 22 | { |
23 | 23 | $fiber = new Fiber($callable); |
24 | 24 | $value = $fiber->start(); |
25 | - while (!$fiber->isTerminated()) { |
|
26 | - if ($check !== null) { |
|
27 | - try { |
|
25 | + while (!$fiber->isTerminated()) |
|
26 | + { |
|
27 | + if ($check !== null) |
|
28 | + { |
|
29 | + try |
|
30 | + { |
|
28 | 31 | $value = $check($value); |
29 | - } catch (\Throwable $e) { |
|
32 | + } |
|
33 | + catch (\Throwable $e) |
|
34 | + { |
|
30 | 35 | $value = $fiber->throw($e); |
31 | 36 | continue; |
32 | 37 | } |
@@ -50,14 +55,17 @@ discard block |
||
50 | 55 | /** Values that were suspended by the fiber. */ |
51 | 56 | $suspends = []; |
52 | 57 | $results = []; |
53 | - foreach ($callables as $key => $callable) { |
|
54 | - $fiberGenerators[$key] = (static function () use ($callable) { |
|
58 | + foreach ($callables as $key => $callable) |
|
59 | + { |
|
60 | + $fiberGenerators[$key] = (static function () use ($callable) |
|
61 | + { |
|
55 | 62 | $fiber = new Fiber($callable); |
56 | 63 | // Get ready |
57 | 64 | yield null; |
58 | 65 | |
59 | 66 | $value = yield $fiber->start(); |
60 | - while (!$fiber->isTerminated()) { |
|
67 | + while (!$fiber->isTerminated()) |
|
68 | + { |
|
61 | 69 | $value = yield $fiber->resume($value); |
62 | 70 | } |
63 | 71 | return $fiber->getReturn(); |
@@ -67,15 +75,21 @@ discard block |
||
67 | 75 | } |
68 | 76 | |
69 | 77 | |
70 | - while ($fiberGenerators !== []) { |
|
71 | - foreach ($fiberGenerators as $key => $generator) { |
|
72 | - try { |
|
78 | + while ($fiberGenerators !== []) |
|
79 | + { |
|
80 | + foreach ($fiberGenerators as $key => $generator) |
|
81 | + { |
|
82 | + try |
|
83 | + { |
|
73 | 84 | $suspends[$key] = $generator->send($suspends[$key]); |
74 | - if (!$generator->valid()) { |
|
85 | + if (!$generator->valid()) |
|
86 | + { |
|
75 | 87 | $results[$key] = $generator->getReturn(); |
76 | 88 | unset($fiberGenerators[$key]); |
77 | 89 | } |
78 | - } catch (\Throwable $e) { |
|
90 | + } |
|
91 | + catch (\Throwable $e) |
|
92 | + { |
|
79 | 93 | unset($fiberGenerators[$key]); |
80 | 94 | $results[$key] = $e; |
81 | 95 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | public function __construct( |
12 | 12 | #[Proxy] public ContextInterface $context, |
13 | - ) { |
|
13 | + ){ |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function getContext(): ContextInterface |
@@ -7,11 +7,11 @@ |
||
7 | 7 | final class Context implements ContextInterface |
8 | 8 | { |
9 | 9 | public function __construct( |
10 | - public \Stringable|string|null $value, |
|
11 | - ) { |
|
10 | + public \Stringable | string | null $value, |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | |
14 | - public function getValue(): \Stringable|string|null |
|
14 | + public function getValue(): \Stringable | string | null |
|
15 | 15 | { |
16 | 16 | return $this->value; |
17 | 17 | } |
@@ -6,5 +6,5 @@ |
||
6 | 6 | |
7 | 7 | interface ContextInterface |
8 | 8 | { |
9 | - public function getValue(): \Stringable|string|null; |
|
9 | + public function getValue(): \Stringable | string | null; |
|
10 | 10 | } |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function __construct( |
15 | 15 | private readonly ContainerInterface $container |
16 | - ) { |
|
16 | + ){ |
|
17 | 17 | } |
18 | 18 | |
19 | - public function __invoke(LogRecord|array $record): array |
|
19 | + public function __invoke(LogRecord | array $record): array |
|
20 | 20 | { |
21 | - if ($record instanceof LogRecord) { |
|
21 | + if ($record instanceof LogRecord){ |
|
22 | 22 | $record = $record->toArray(); |
23 | 23 | } |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | $context = $tracer->getContext(); |
29 | 29 | |
30 | - if (!empty($context)) { |
|
30 | + if (!empty($context)){ |
|
31 | 31 | $record['extra']['telemetry'] = $context; |
32 | 32 | } |
33 | 33 |
@@ -18,7 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | public function __invoke(LogRecord|array $record): array |
20 | 20 | { |
21 | - if ($record instanceof LogRecord) { |
|
21 | + if ($record instanceof LogRecord) |
|
22 | + { |
|
22 | 23 | $record = $record->toArray(); |
23 | 24 | } |
24 | 25 | |
@@ -27,7 +28,8 @@ discard block |
||
27 | 28 | |
28 | 29 | $context = $tracer->getContext(); |
29 | 30 | |
30 | - if (!empty($context)) { |
|
31 | + if (!empty($context)) |
|
32 | + { |
|
31 | 33 | $record['extra']['telemetry'] = $context; |
32 | 34 | } |
33 | 35 |
@@ -12,6 +12,6 @@ |
||
12 | 12 | trait ProxyTrait |
13 | 13 | { |
14 | 14 | private static string $__container_proxy_alias; |
15 | - private \Stringable|string|null $__container_proxy_context = null; |
|
15 | + private \Stringable | string | null $__container_proxy_context = null; |
|
16 | 16 | private ?ContainerInterface $__container_proxy_container = null; |
17 | 17 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | private function makeEmptyErrorHandler(): ExceptionHandler |
141 | 141 | { |
142 | - return new class extends ExceptionHandler { |
|
142 | + return new class extends ExceptionHandler{ |
|
143 | 143 | protected function bootBasicHandlers(): void |
144 | 144 | { |
145 | 145 | } |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | public static function nonReportableExceptionsDataProvider(): \Traversable |
155 | 155 | { |
156 | 156 | yield [new BadRequestException()]; |
157 | - yield [new class extends BadRequestException {}]; |
|
157 | + yield [new class extends BadRequestException{}]; |
|
158 | 158 | yield [new NotFoundException()]; |
159 | - yield [new class extends NotFoundException {}]; |
|
159 | + yield [new class extends NotFoundException{}]; |
|
160 | 160 | yield [new ForbiddenException()]; |
161 | - yield [new class extends ForbiddenException {}]; |
|
161 | + yield [new class extends ForbiddenException{}]; |
|
162 | 162 | yield [new UnauthorizedException()]; |
163 | - yield [new class extends UnauthorizedException {}]; |
|
163 | + yield [new class extends UnauthorizedException{}]; |
|
164 | 164 | yield [new AuthorizationException()]; |
165 | - yield [new class extends AuthorizationException {}]; |
|
165 | + yield [new class extends AuthorizationException{}]; |
|
166 | 166 | yield [new ValidationException([])]; |
167 | - yield [new class([]) extends ValidationException {}]; |
|
167 | + yield [new class([]) extends ValidationException{}]; |
|
168 | 168 | yield [new TestException()]; |
169 | 169 | } |
170 | 170 | } |
@@ -139,7 +139,8 @@ discard block |
||
139 | 139 | |
140 | 140 | private function makeEmptyErrorHandler(): ExceptionHandler |
141 | 141 | { |
142 | - return new class extends ExceptionHandler { |
|
142 | + return new class extends ExceptionHandler |
|
143 | + { |
|
143 | 144 | protected function bootBasicHandlers(): void |
144 | 145 | { |
145 | 146 | } |
@@ -154,17 +155,29 @@ discard block |
||
154 | 155 | public static function nonReportableExceptionsDataProvider(): \Traversable |
155 | 156 | { |
156 | 157 | yield [new BadRequestException()]; |
157 | - yield [new class extends BadRequestException {}]; |
|
158 | + yield [new class extends BadRequestException |
|
159 | + { |
|
160 | +}]; |
|
158 | 161 | yield [new NotFoundException()]; |
159 | - yield [new class extends NotFoundException {}]; |
|
162 | + yield [new class extends NotFoundException |
|
163 | + { |
|
164 | +}]; |
|
160 | 165 | yield [new ForbiddenException()]; |
161 | - yield [new class extends ForbiddenException {}]; |
|
166 | + yield [new class extends ForbiddenException |
|
167 | + { |
|
168 | +}]; |
|
162 | 169 | yield [new UnauthorizedException()]; |
163 | - yield [new class extends UnauthorizedException {}]; |
|
170 | + yield [new class extends UnauthorizedException |
|
171 | + { |
|
172 | +}]; |
|
164 | 173 | yield [new AuthorizationException()]; |
165 | - yield [new class extends AuthorizationException {}]; |
|
174 | + yield [new class extends AuthorizationException |
|
175 | + { |
|
176 | +}]; |
|
166 | 177 | yield [new ValidationException([])]; |
167 | - yield [new class([]) extends ValidationException {}]; |
|
178 | + yield [new class([]) extends ValidationException |
|
179 | + { |
|
180 | +}]; |
|
168 | 181 | yield [new TestException()]; |
169 | 182 | } |
170 | 183 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function create( |
24 | 24 | \ReflectionClass $type, |
25 | - \Stringable|string|null $context, |
|
25 | + \Stringable | string | null $context, |
|
26 | 26 | \Spiral\Core\Attribute\Proxy $attribute, |
27 | 27 | ): object { |
28 | 28 | $interface = $type->getName(); |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
38 | 38 | ); |
39 | 39 | |
40 | - if (!\array_key_exists($cacheKey, self::$classes)) { |
|
40 | + if (!\array_key_exists($cacheKey, self::$classes)){ |
|
41 | 41 | $n = 0; |
42 | - do { |
|
42 | + do{ |
|
43 | 43 | $className = \sprintf( |
44 | 44 | '%s\%s SCOPED PROXY%s', |
45 | 45 | $type->getNamespaceName(), |
46 | 46 | $type->getShortName(), |
47 | 47 | $n++ > 0 ? " {$n}" : '' |
48 | 48 | ); |
49 | - } while (\class_exists($className)); |
|
49 | + }while (\class_exists($className)); |
|
50 | 50 | |
51 | 51 | /** @var class-string<TClass> $className */ |
52 | - try { |
|
52 | + try{ |
|
53 | 53 | $classString = ProxyClassRenderer::renderClass( |
54 | 54 | $type, |
55 | 55 | $className, |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | eval($classString); |
61 | - } catch (\Throwable $e) { |
|
61 | + }catch (\Throwable $e){ |
|
62 | 62 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
63 | 63 | } |
64 | 64 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | // Store in cache without context |
69 | 69 | self::$classes[$cacheKey] = $className; |
70 | - } else { |
|
70 | + }else{ |
|
71 | 71 | /** @var TClass $instance */ |
72 | 72 | $instance = new (self::$classes[$cacheKey])(); |
73 | 73 | } |
74 | 74 | |
75 | - if ($context !== null || $attachContainer) { |
|
75 | + if ($context !== null || $attachContainer){ |
|
76 | 76 | (static function () use ($instance, $context, $attachContainer): void { |
77 | 77 | // Set the Current Context |
78 | 78 | /** @see \Spiral\Core\Internal\Proxy\ProxyTrait::$__container_proxy_context */ |
@@ -37,9 +37,11 @@ discard block |
||
37 | 37 | $attribute->proxyOverloads ? '[magic-calls]' : '', |
38 | 38 | ); |
39 | 39 | |
40 | - if (!\array_key_exists($cacheKey, self::$classes)) { |
|
40 | + if (!\array_key_exists($cacheKey, self::$classes)) |
|
41 | + { |
|
41 | 42 | $n = 0; |
42 | - do { |
|
43 | + do |
|
44 | + { |
|
43 | 45 | $className = \sprintf( |
44 | 46 | '%s\%s SCOPED PROXY%s', |
45 | 47 | $type->getNamespaceName(), |
@@ -49,7 +51,8 @@ discard block |
||
49 | 51 | } while (\class_exists($className)); |
50 | 52 | |
51 | 53 | /** @var class-string<TClass> $className */ |
52 | - try { |
|
54 | + try |
|
55 | + { |
|
53 | 56 | $classString = ProxyClassRenderer::renderClass( |
54 | 57 | $type, |
55 | 58 | $className, |
@@ -58,7 +61,9 @@ discard block |
||
58 | 61 | ); |
59 | 62 | |
60 | 63 | eval($classString); |
61 | - } catch (\Throwable $e) { |
|
64 | + } |
|
65 | + catch (\Throwable $e) |
|
66 | + { |
|
62 | 67 | throw new \Error("Unable to create proxy for `{$interface}`: {$e->getMessage()}", 0, $e); |
63 | 68 | } |
64 | 69 | |
@@ -67,12 +72,15 @@ discard block |
||
67 | 72 | |
68 | 73 | // Store in cache without context |
69 | 74 | self::$classes[$cacheKey] = $className; |
70 | - } else { |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
71 | 78 | /** @var TClass $instance */ |
72 | 79 | $instance = new (self::$classes[$cacheKey])(); |
73 | 80 | } |
74 | 81 | |
75 | - if ($context !== null || $attachContainer) { |
|
82 | + if ($context !== null || $attachContainer) |
|
83 | + { |
|
76 | 84 | (static function () use ($instance, $context, $attachContainer): void { |
77 | 85 | // Set the Current Context |
78 | 86 | /** @see \Spiral\Core\Internal\Proxy\ProxyTrait::$__container_proxy_context */ |
@@ -46,7 +46,9 @@ |
||
46 | 46 | $binder = $this->constructor->get('binder', BinderInterface::class); |
47 | 47 | $factory = $this->constructor->get('factory', FactoryInterface::class); |
48 | 48 | |
49 | - $this->bindSingleton('test', new #[Singleton] class {}); |
|
49 | + $this->bindSingleton('test', new #[Singleton] class |
|
50 | + { |
|
51 | +}); |
|
50 | 52 | $factory->make('test'); |
51 | 53 | |
52 | 54 | $this->assertTrue($binder->hasInstance('test')); |