@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | yield [$from(fn(string $string = self::STRING_CONST) => 0), 'mixed $string = self::STRING_CONST']; |
57 | 57 | yield [ |
58 | 58 | $from(fn(string $string = ProxyClassRendererTest::STRING_CONST) => 0), |
59 | - 'mixed $string = \\' . self::class . '::STRING_CONST', |
|
59 | + 'mixed $string = \\'.self::class.'::STRING_CONST', |
|
60 | 60 | ]; |
61 | - yield [$from(fn(string|int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
61 | + yield [$from(fn(string | int $string = self::INT_CONST) => 0), 'mixed $string = self::INT_CONST']; |
|
62 | 62 | yield [$from(fn(mixed $string = 42) => 0), 'mixed $string = 42']; |
63 | 63 | yield [$from(fn(int $string = 42) => 0), 'mixed $string = 42']; |
64 | 64 | yield [$from(fn(float $string = 42) => 0), 'mixed $string = 42.0']; |
65 | 65 | yield [$from(fn(?bool $string = false) => 0), 'mixed $string = false']; |
66 | - yield [$from(fn(bool|null $string = true) => 0), 'mixed $string = true']; |
|
66 | + yield [$from(fn(bool | null $string = true) => 0), 'mixed $string = true']; |
|
67 | 67 | yield [$from(fn(object $string = null) => 0), 'mixed $string = NULL']; |
68 | 68 | yield [$from(fn(iterable $string = null) => 0), 'mixed $string = NULL']; |
69 | 69 | yield [$from(fn(Countable&ArrayAccess $val) => 0), 'mixed $val']; |
70 | 70 | yield [$from(fn(string ...$val) => 0), 'mixed ...$val']; |
71 | - yield [$from(fn(string|int ...$val) => 0), 'mixed ...$val']; |
|
72 | - yield [$from(fn(string|int &$link) => 0), 'mixed &$link']; |
|
71 | + yield [$from(fn(string | int ...$val) => 0), 'mixed ...$val']; |
|
72 | + yield [$from(fn(string | int &$link) => 0), 'mixed &$link']; |
|
73 | 73 | yield [$from(self::withSelf(...)), 'mixed $self = new self()']; |
74 | 74 | yield [$from(fn(object $link = new \stdClass()) => 0), 'mixed $link = new \stdClass()']; |
75 | 75 | yield [ |
76 | - $from(fn(#[Proxy] float|int|\stdClass|null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
76 | + $from(fn(#[Proxy] float | int | \stdClass | null $string = new \stdClass(1, 2, bar: "\n'zero")) => 0), |
|
77 | 77 | "mixed \$string = new \stdClass(1, 2, bar: '\n\'zero')", |
78 | 78 | ]; |
79 | 79 | yield [ |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | public const INT_CONST = 42; |
98 | 98 | |
99 | 99 | #[ExpectedAttribute('public function test1(...$variadic)')] |
100 | - public function test1(...$variadic) {} |
|
100 | + public function test1(...$variadic){} |
|
101 | 101 | #[ExpectedAttribute('public function test2(mixed $string = self::INT_CONST): string|int')] |
102 | - public function test2(string|int $string = self::INT_CONST): string|int {} |
|
102 | + public function test2(string | int $string = self::INT_CONST): string | int {} |
|
103 | 103 | #[ExpectedAttribute('public function test3(mixed $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
104 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
105 | - #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
|
104 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())){} |
|
105 | + #[ExpectedAttribute('public function test4(): \\'.ProxyClassRendererTest::class)] |
|
106 | 106 | public function test4(): ProxyClassRendererTest {} |
107 | 107 | #[ExpectedAttribute('public function &test5(): string')] |
108 | 108 | public function &test5(): string {} |
109 | 109 | }; |
110 | 110 | |
111 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
111 | + foreach ((new \ReflectionClass($class))->getMethods() as $method){ |
|
112 | 112 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
113 | 113 | |
114 | 114 | yield [$method, $expected->value]; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | $from = static fn(\Closure $closure): \ReflectionParameter => new \ReflectionParameter($closure, 0); |
146 | 146 | |
147 | 147 | yield [$from(fn(string $string) => 0), 'string']; |
148 | - yield [$from(fn(string|int $string) => 0), 'string|int']; |
|
148 | + yield [$from(fn(string | int $string) => 0), 'string|int']; |
|
149 | 149 | yield [$from(fn(mixed $string) => 0), 'mixed']; |
150 | 150 | yield [$from(fn(int $string) => 0), 'int']; |
151 | 151 | yield [$from(fn(float $string) => 0), 'float']; |
152 | 152 | yield [$from(fn(?bool $string) => 0), '?bool']; |
153 | - yield [$from(fn(bool|null $string) => 0), '?bool']; |
|
153 | + yield [$from(fn(bool | null $string) => 0), '?bool']; |
|
154 | 154 | yield [$from(fn(object $string) => 0), 'object']; |
155 | 155 | yield [$from(fn(iterable $string) => 0), 'iterable']; |
156 | 156 | yield [$from(fn(Countable&ArrayAccess $val) => 0), '\Countable&\ArrayAccess']; |
157 | 157 | yield [$from(fn(string ...$val) => 0), 'string']; |
158 | - yield [$from(fn(string|int ...$val) => 0), 'string|int']; |
|
159 | - yield [$from(fn(string|int &$link) => 0), 'string|int']; |
|
160 | - yield [$from(self::withSelf(...)), '\\' . self::class]; |
|
158 | + yield [$from(fn(string | int ...$val) => 0), 'string|int']; |
|
159 | + yield [$from(fn(string | int &$link) => 0), 'string|int']; |
|
160 | + yield [$from(self::withSelf(...)), '\\'.self::class]; |
|
161 | 161 | yield [$from(fn(object $link) => 0), 'object']; |
162 | - yield [$from(fn(#[Proxy] float|int|\stdClass|null $string) => 0), '\stdClass|int|float|null']; |
|
163 | - yield [$from(fn(SimpleEnum $val) => 0), '\\' . SimpleEnum::class]; |
|
162 | + yield [$from(fn(#[Proxy] float | int | \stdClass | null $string) => 0), '\stdClass|int|float|null']; |
|
163 | + yield [$from(fn(SimpleEnum $val) => 0), '\\'.SimpleEnum::class]; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | private static function withSelf(self $self = new self()): void |
@@ -173,6 +173,6 @@ discard block |
||
173 | 173 | { |
174 | 174 | public function __construct( |
175 | 175 | public readonly string $value, |
176 | - ) { |
|
176 | + ){ |
|
177 | 177 | } |
178 | 178 | } |
@@ -93,22 +93,28 @@ |
||
93 | 93 | |
94 | 94 | public static function provideRenderMethod(): iterable |
95 | 95 | { |
96 | - $class = new class { |
|
96 | + $class = new class |
|
97 | + { |
|
97 | 98 | public const INT_CONST = 42; |
98 | 99 | |
99 | 100 | #[ExpectedAttribute('public function test1(...$variadic)')] |
100 | - public function test1(...$variadic) {} |
|
101 | + public function test1(...$variadic) |
|
102 | + { |
|
103 | +} |
|
101 | 104 | #[ExpectedAttribute('public function test2(mixed $string = self::INT_CONST): string|int')] |
102 | 105 | public function test2(string|int $string = self::INT_CONST): string|int {} |
103 | 106 | #[ExpectedAttribute('public function test3(mixed $obj = new \stdClass(new \stdClass(), new \stdClass()))')] |
104 | - public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) {} |
|
107 | + public function test3(object $obj = new stdClass(new stdClass(), new stdClass())) |
|
108 | + { |
|
109 | +} |
|
105 | 110 | #[ExpectedAttribute('public function test4(): \\' . ProxyClassRendererTest::class)] |
106 | 111 | public function test4(): ProxyClassRendererTest {} |
107 | 112 | #[ExpectedAttribute('public function &test5(): string')] |
108 | 113 | public function &test5(): string {} |
109 | 114 | }; |
110 | 115 | |
111 | - foreach ((new \ReflectionClass($class))->getMethods() as $method) { |
|
116 | + foreach ((new \ReflectionClass($class))->getMethods() as $method) |
|
117 | + { |
|
112 | 118 | $expected = $method->getAttributes(ExpectedAttribute::class)[0]->newInstance(); |
113 | 119 | |
114 | 120 | yield [$method, $expected->value]; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | // from the current `foo` scope |
47 | 47 | self::assertInstanceOf(KVLogger::class, $logger); |
48 | 48 | |
49 | - for ($i = 0; $i < 10; $i++) { |
|
49 | + for ($i = 0; $i < 10; $i++){ |
|
50 | 50 | // because of proxy |
51 | 51 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
52 | 52 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | // from the current `foo` scope |
67 | 67 | self::assertInstanceOf(FileLogger::class, $logger); |
68 | 68 | |
69 | - for ($i = 0; $i < 10; $i++) { |
|
69 | + for ($i = 0; $i < 10; $i++){ |
|
70 | 70 | // because of proxy |
71 | 71 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
72 | 72 | self::assertSame('file', $carrier->logger->getName()); |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | $root = new Container(); |
84 | 84 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
85 | 85 | |
86 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
86 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
87 | 87 | $c1->runScope( |
88 | 88 | new Scope(name: 'http'), |
89 | 89 | static function ( |
90 | 90 | ScopedProxyLoggerCarrier $carrier, |
91 | 91 | ScopedProxyLoggerCarrier $carrier2, |
92 | 92 | LoggerInterface $logger |
93 | - ) { |
|
93 | + ){ |
|
94 | 94 | // from the current `foo` scope |
95 | 95 | self::assertInstanceOf(KVLogger::class, $logger); |
96 | 96 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | $root = new Container(); |
111 | 111 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
112 | 112 | |
113 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
113 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
114 | 114 | $c1->runScope( |
115 | 115 | new Scope(name: 'foo'), |
116 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
116 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger){ |
|
117 | 117 | // from the current `foo` scope |
118 | 118 | self::assertInstanceOf(KVLogger::class, $logger); |
119 | 119 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | ->bind( |
135 | 135 | ContextInterface::class, |
136 | 136 | new \Spiral\Core\Config\Injectable( |
137 | - new class implements InjectorInterface { |
|
137 | + new class implements InjectorInterface{ |
|
138 | 138 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
139 | 139 | { |
140 | 140 | return new Context($context); |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | |
146 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
147 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
146 | + $root->runScope(new Scope(), static function (Container $c1){ |
|
147 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param){ |
|
148 | 148 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
149 | 149 | self::assertSame('param', $param->value->getName()); |
150 | 150 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ->bind( |
176 | 176 | ContextInterface::class, |
177 | 177 | new \Spiral\Core\Config\Injectable( |
178 | - new class implements InjectorInterface { |
|
178 | + new class implements InjectorInterface{ |
|
179 | 179 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
180 | 180 | { |
181 | 181 | return new Context($context); |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | ); |
186 | 186 | |
187 | 187 | FiberHelper::runFiberSequence( |
188 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
189 | - for ($i = 0; $i < 10; $i++) { |
|
188 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx){ |
|
189 | + for ($i = 0; $i < 10; $i++){ |
|
190 | 190 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
191 | 191 | self::assertSame('ctx', $ctx->getValue()->getName()); |
192 | 192 | \Fiber::suspend(); |
193 | 193 | } |
194 | 194 | }), |
195 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
196 | - for ($i = 0; $i < 10; $i++) { |
|
195 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context){ |
|
196 | + for ($i = 0; $i < 10; $i++){ |
|
197 | 197 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
198 | 198 | self::assertSame('context', $context->getValue()->getName()); |
199 | 199 | \Fiber::suspend(); |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | { |
255 | 255 | $root = new Container(); |
256 | 256 | $context = (object)['destroyed' => false]; |
257 | - $class = new class($context) implements DestroyableInterface { |
|
257 | + $class = new class($context) implements DestroyableInterface{ |
|
258 | 258 | public function __construct( |
259 | 259 | private readonly \stdClass $context, |
260 | - ) { |
|
260 | + ){ |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public function __destruct() |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | new Scope('http'), |
286 | 286 | static function () use ($root, $proxy) { |
287 | 287 | self::assertSame('Foo', $proxy->getName()); |
288 | - $proxy->setName(new class implements \Stringable { |
|
288 | + $proxy->setName(new class implements \Stringable{ |
|
289 | 289 | public function __toString(): string |
290 | 290 | { |
291 | 291 | return 'Bar'; |
@@ -42,11 +42,13 @@ discard block |
||
42 | 42 | LoggerInterface::class => KVLogger::class, |
43 | 43 | ], |
44 | 44 | ), |
45 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
45 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
46 | + { |
|
46 | 47 | // from the current `foo` scope |
47 | 48 | self::assertInstanceOf(KVLogger::class, $logger); |
48 | 49 | |
49 | - for ($i = 0; $i < 10; $i++) { |
|
50 | + for ($i = 0; $i < 10; $i++) |
|
51 | + { |
|
50 | 52 | // because of proxy |
51 | 53 | self::assertNotInstanceOf(KVLogger::class, $carrier->getLogger()); |
52 | 54 | self::assertSame('kv', $carrier->logger->getName()); |
@@ -62,11 +64,13 @@ discard block |
||
62 | 64 | LoggerInterface::class => FileLogger::class, |
63 | 65 | ], |
64 | 66 | ), |
65 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) { |
|
67 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) use ($lc) |
|
68 | + { |
|
66 | 69 | // from the current `foo` scope |
67 | 70 | self::assertInstanceOf(FileLogger::class, $logger); |
68 | 71 | |
69 | - for ($i = 0; $i < 10; $i++) { |
|
72 | + for ($i = 0; $i < 10; $i++) |
|
73 | + { |
|
70 | 74 | // because of proxy |
71 | 75 | self::assertNotInstanceOf(FileLogger::class, $carrier->getLogger()); |
72 | 76 | self::assertSame('file', $carrier->logger->getName()); |
@@ -83,7 +87,8 @@ discard block |
||
83 | 87 | $root = new Container(); |
84 | 88 | $root->getBinder('http')->bindSingleton(LoggerInterface::class, KVLogger::class); |
85 | 89 | |
86 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
90 | + $root->runScope(new Scope(), static function (Container $c1) |
|
91 | + { |
|
87 | 92 | $c1->runScope( |
88 | 93 | new Scope(name: 'http'), |
89 | 94 | static function ( |
@@ -110,10 +115,12 @@ discard block |
||
110 | 115 | $root = new Container(); |
111 | 116 | $root->getBinder('foo')->bind(LoggerInterface::class, KVLogger::class); |
112 | 117 | |
113 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
118 | + $root->runScope(new Scope(), static function (Container $c1) |
|
119 | + { |
|
114 | 120 | $c1->runScope( |
115 | 121 | new Scope(name: 'foo'), |
116 | - static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) { |
|
122 | + static function (ScopedProxyLoggerCarrier $carrier, LoggerInterface $logger) |
|
123 | + { |
|
117 | 124 | // from the current `foo` scope |
118 | 125 | self::assertInstanceOf(KVLogger::class, $logger); |
119 | 126 | |
@@ -134,7 +141,8 @@ discard block |
||
134 | 141 | ->bind( |
135 | 142 | ContextInterface::class, |
136 | 143 | new \Spiral\Core\Config\Injectable( |
137 | - new class implements InjectorInterface { |
|
144 | + new class implements InjectorInterface |
|
145 | + { |
|
138 | 146 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
139 | 147 | { |
140 | 148 | return new Context($context); |
@@ -143,8 +151,10 @@ discard block |
||
143 | 151 | ) |
144 | 152 | ); |
145 | 153 | |
146 | - $root->runScope(new Scope(), static function (Container $c1) { |
|
147 | - $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) { |
|
154 | + $root->runScope(new Scope(), static function (Container $c1) |
|
155 | + { |
|
156 | + $c1->runScope(new Scope(name: 'foo'), static function (Container $c, ContextInterface $param) |
|
157 | + { |
|
148 | 158 | self::assertInstanceOf(ReflectionParameter::class, $param->value); |
149 | 159 | self::assertSame('param', $param->value->getName()); |
150 | 160 | |
@@ -175,7 +185,8 @@ discard block |
||
175 | 185 | ->bind( |
176 | 186 | ContextInterface::class, |
177 | 187 | new \Spiral\Core\Config\Injectable( |
178 | - new class implements InjectorInterface { |
|
188 | + new class implements InjectorInterface |
|
189 | + { |
|
179 | 190 | public function createInjection(\ReflectionClass $class, mixed $context = null): Context |
180 | 191 | { |
181 | 192 | return new Context($context); |
@@ -185,15 +196,19 @@ discard block |
||
185 | 196 | ); |
186 | 197 | |
187 | 198 | FiberHelper::runFiberSequence( |
188 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) { |
|
189 | - for ($i = 0; $i < 10; $i++) { |
|
199 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $ctx) |
|
200 | + { |
|
201 | + for ($i = 0; $i < 10; $i++) |
|
202 | + { |
|
190 | 203 | self::assertInstanceOf(ReflectionParameter::class, $ctx->getValue(), 'Context injected'); |
191 | 204 | self::assertSame('ctx', $ctx->getValue()->getName()); |
192 | 205 | \Fiber::suspend(); |
193 | 206 | } |
194 | 207 | }), |
195 | - static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) { |
|
196 | - for ($i = 0; $i < 10; $i++) { |
|
208 | + static fn() => $root->runScope(new Scope(name: 'foo'), static function (ContextInterface $context) |
|
209 | + { |
|
210 | + for ($i = 0; $i < 10; $i++) |
|
211 | + { |
|
197 | 212 | self::assertInstanceOf(ReflectionParameter::class, $context->getValue(), 'Context injected'); |
198 | 213 | self::assertSame('context', $context->getValue()->getName()); |
199 | 214 | \Fiber::suspend(); |
@@ -209,8 +224,10 @@ discard block |
||
209 | 224 | |
210 | 225 | $root->runScope( |
211 | 226 | new Scope(), |
212 | - static function (#[Proxy] ContainerInterface $cp) use ($root) { |
|
213 | - $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) { |
|
227 | + static function (#[Proxy] ContainerInterface $cp) use ($root) |
|
228 | + { |
|
229 | + $root->runScope(new Scope(name: 'http'), static function (ContainerInterface $c) use ($cp) |
|
230 | + { |
|
214 | 231 | self::assertNotSame($c, $cp); |
215 | 232 | self::assertSame($c, $cp->get(ContainerInterface::class)); |
216 | 233 | self::assertInstanceOf(KVLogger::class, $cp->get(LoggerInterface::class)); |
@@ -254,7 +271,8 @@ discard block |
||
254 | 271 | { |
255 | 272 | $root = new Container(); |
256 | 273 | $context = (object)['destroyed' => false]; |
257 | - $class = new class($context) implements DestroyableInterface { |
|
274 | + $class = new class($context) implements DestroyableInterface |
|
275 | + { |
|
258 | 276 | public function __construct( |
259 | 277 | private readonly \stdClass $context, |
260 | 278 | ) { |
@@ -283,7 +301,8 @@ discard block |
||
283 | 301 | |
284 | 302 | $root->runScope( |
285 | 303 | new Scope('http'), |
286 | - static function () use ($root, $proxy) { |
|
304 | + static function () use ($root, $proxy) |
|
305 | + { |
|
287 | 306 | self::assertSame('Foo', $proxy->getName()); |
288 | 307 | $proxy->setName(new class implements \Stringable { |
289 | 308 | public function __toString(): string |
@@ -8,12 +8,12 @@ |
||
8 | 8 | { |
9 | 9 | public function __construct( |
10 | 10 | private string $name, |
11 | - ) { |
|
11 | + ){ |
|
12 | 12 | } |
13 | 13 | |
14 | - public function setName(string|\Stringable $name): void |
|
14 | + public function setName(string | \Stringable $name): void |
|
15 | 15 | { |
16 | - $this->name = (string) $name; |
|
16 | + $this->name = (string)$name; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | public function getName(): string |
@@ -27,29 +27,29 @@ discard block |
||
27 | 27 | MagicCallTrait::class, |
28 | 28 | ] : []; |
29 | 29 | |
30 | - if (\str_contains($className, '\\')) { |
|
30 | + if (\str_contains($className, '\\')){ |
|
31 | 31 | $classShortName = \substr($className, \strrpos($className, '\\') + 1); |
32 | - $classNamespaceStr = 'namespace ' . \substr($className, 0, \strrpos($className, '\\')) . ';'; |
|
33 | - } else { |
|
32 | + $classNamespaceStr = 'namespace '.\substr($className, 0, \strrpos($className, '\\')).';'; |
|
33 | + }else{ |
|
34 | 34 | $classShortName = $className; |
35 | 35 | $classNamespaceStr = ''; |
36 | 36 | } |
37 | 37 | |
38 | 38 | $interface = $type->getName(); |
39 | 39 | $classBody = []; |
40 | - foreach ($type->getMethods() as $method) { |
|
41 | - if ($method->isConstructor()) { |
|
40 | + foreach ($type->getMethods() as $method){ |
|
41 | + if ($method->isConstructor()){ |
|
42 | 42 | throw new \LogicException('Constructor is not allowed in a proxy.'); |
43 | 43 | } |
44 | 44 | |
45 | - if ($method->isDestructor()) { |
|
45 | + if ($method->isDestructor()){ |
|
46 | 46 | $classBody[] = self::renderMethod($method); |
47 | 47 | continue; |
48 | 48 | } |
49 | 49 | |
50 | 50 | $hasRefs = false; |
51 | 51 | $return = $method->hasReturnType() && (string)$method->getReturnType() === 'void' ? '' : 'return '; |
52 | - $call = ($method->isStatic() ? '::' : '->') . $method->getName(); |
|
52 | + $call = ($method->isStatic() ? '::' : '->').$method->getName(); |
|
53 | 53 | $context = $method->isStatic() ? 'null' : '$this->__container_proxy_context'; |
54 | 54 | $containerStr = match (false) { |
55 | 55 | $attachContainer => 'null', |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | PHP; |
70 | 70 | |
71 | 71 | $args = []; |
72 | - foreach ($method->getParameters() as $param) { |
|
72 | + foreach ($method->getParameters() as $param){ |
|
73 | 73 | $hasRefs = $hasRefs || $param->isPassedByReference(); |
74 | - $args[] = ($param->isVariadic() ? '...' : '') . '$' . $param->getName(); |
|
74 | + $args[] = ($param->isVariadic() ? '...' : '').'$'.$param->getName(); |
|
75 | 75 | } |
76 | 76 | |
77 | - if (!$hasRefs && !$method->isVariadic()) { |
|
77 | + if (!$hasRefs && !$method->isVariadic()){ |
|
78 | 78 | $classBody[] = self::renderMethod( |
79 | 79 | $method, |
80 | 80 | <<<PHP |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $argsStr = \implode(', ', $args); |
88 | 88 | |
89 | - if ($method->isVariadic()) { |
|
89 | + if ($method->isVariadic()){ |
|
90 | 90 | $classBody[] = self::renderMethod( |
91 | 91 | $method, |
92 | 92 | <<<PHP |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | $traitsStr = $traits === [] ? '' : \implode( |
110 | 110 | "\n ", |
111 | - \array_map(fn (string $trait): string => 'use \\' . \ltrim($trait, '\\') . ';', $traits) |
|
111 | + \array_map(fn (string $trait) : string => 'use \\'.\ltrim($trait, '\\').';', $traits) |
|
112 | 112 | ); |
113 | 113 | return <<<PHP |
114 | 114 | $classNamespaceStr |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $m->getName(), |
132 | 132 | \implode(', ', \array_map([self::class, 'renderParameter'], $m->getParameters())), |
133 | 133 | $m->hasReturnType() |
134 | - ? ': ' . self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
134 | + ? ': '.self::renderParameterTypes($m->getReturnType(), $m->getDeclaringClass()) |
|
135 | 135 | : '', |
136 | 136 | $body, |
137 | 137 | ); |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | $param->hasType() ? 'mixed' : '', |
146 | 146 | $param->isPassedByReference() ? '&' : '', |
147 | 147 | $param->isVariadic() ? '...' : '', |
148 | - '$' . $param->getName(), |
|
149 | - $param->isOptional() && !$param->isVariadic() ? ' = ' . self::renderDefaultValue($param) : '', |
|
148 | + '$'.$param->getName(), |
|
149 | + $param->isOptional() && !$param->isVariadic() ? ' = '.self::renderDefaultValue($param) : '', |
|
150 | 150 | ), |
151 | 151 | ' ' |
152 | 152 | ); |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | |
155 | 155 | public static function renderParameterTypes(\ReflectionType $types, \ReflectionClass $class): string |
156 | 156 | { |
157 | - if ($types instanceof \ReflectionNamedType) { |
|
158 | - return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '') . ($types->isBuiltin() |
|
157 | + if ($types instanceof \ReflectionNamedType){ |
|
158 | + return ($types->allowsNull() && $types->getName() !== 'mixed' ? '?' : '').($types->isBuiltin() |
|
159 | 159 | ? $types->getName() |
160 | 160 | : self::normalizeClassType($types, $class)); |
161 | 161 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | }; |
168 | 168 | |
169 | 169 | $result = []; |
170 | - foreach ($types as $type) { |
|
170 | + foreach ($types as $type){ |
|
171 | 171 | $result[] = $type->isBuiltin() |
172 | 172 | ? $type->getName() |
173 | 173 | : self::normalizeClassType($type, $class); |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | |
179 | 179 | public static function renderDefaultValue(\ReflectionParameter $param): string |
180 | 180 | { |
181 | - if ($param->isDefaultValueConstant()) { |
|
181 | + if ($param->isDefaultValueConstant()){ |
|
182 | 182 | $result = $param->getDefaultValueConstantName(); |
183 | 183 | |
184 | 184 | return \explode('::', $result)[0] === 'self' |
185 | 185 | ? $result |
186 | - : '\\' . $result; |
|
186 | + : '\\'.$result; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $cut = self::cutDefaultValue($param); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | public static function normalizeClassType(\ReflectionNamedType $type, \ReflectionClass $class): string |
197 | 197 | { |
198 | - return '\\' . ($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
198 | + return '\\'.($type->getName() === 'self' ? $class->getName() : $type->getName()); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | private static function cutDefaultValue(\ReflectionParameter $param): string |