@@ -23,7 +23,7 @@ |
||
23 | 23 | |
24 | 24 | $this->container = new Container(); |
25 | 25 | $this->container->bind(Tokenizer::class, $this->getTokenizer(['scopes' => [ |
26 | - 'foo' => ['directories' => [__DIR__ . '/Classes/Inner'], 'exclude' => []], |
|
26 | + 'foo' => ['directories' => [__DIR__.'/Classes/Inner'], 'exclude' => []], |
|
27 | 27 | ]])); |
28 | 28 | $this->container->bindSingleton(ScopedClassesInterface::class, ScopedClassLocator::class); |
29 | 29 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | protected function setUp(): void |
17 | 17 | { |
18 | 18 | $this->finder = new Finder(); |
19 | - $this->finder->files()->in([__DIR__ . '/Classes'])->name('*.php'); |
|
19 | + $this->finder->files()->in([__DIR__.'/Classes'])->name('*.php'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function testHasIncludesMessage(): void |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | ); |
57 | 57 | $class->setLogger($logger); |
58 | 58 | |
59 | - try { |
|
59 | + try{ |
|
60 | 60 | $ref->invoke($class, 'foo'); |
61 | - } catch (LocatorException) { |
|
61 | + }catch (LocatorException){ |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | $logger->expects($this->never())->method('error'); |
72 | 72 | $class->setLogger($logger); |
73 | 73 | |
74 | - try { |
|
74 | + try{ |
|
75 | 75 | $ref->invoke($class, 'foo'); |
76 | - } catch (LocatorException) { |
|
76 | + }catch (LocatorException){ |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | ); |
90 | 90 | $class->setLogger($logger); |
91 | 91 | |
92 | - try { |
|
92 | + try{ |
|
93 | 93 | $ref->invoke($class, 'foo'); |
94 | - } catch (LocatorException) { |
|
94 | + }catch (LocatorException){ |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | $logger->expects($this->never())->method('error'); |
105 | 105 | $class->setLogger($logger); |
106 | 106 | |
107 | - try { |
|
107 | + try{ |
|
108 | 108 | $ref->invoke($class, 'foo'); |
109 | - } catch (LocatorException) { |
|
109 | + }catch (LocatorException){ |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
113 | 113 | private function getLocator(bool $debug = false): AbstractLocator |
114 | 114 | { |
115 | - return new class($this->finder, $debug) extends AbstractLocator {}; |
|
115 | + return new class($this->finder, $debug) extends AbstractLocator{}; |
|
116 | 116 | } |
117 | 117 | } |
@@ -56,9 +56,12 @@ discard block |
||
56 | 56 | ); |
57 | 57 | $class->setLogger($logger); |
58 | 58 | |
59 | - try { |
|
59 | + try |
|
60 | + { |
|
60 | 61 | $ref->invoke($class, 'foo'); |
61 | - } catch (LocatorException) { |
|
62 | + } |
|
63 | + catch (LocatorException) |
|
64 | + { |
|
62 | 65 | } |
63 | 66 | } |
64 | 67 | |
@@ -71,9 +74,12 @@ discard block |
||
71 | 74 | $logger->expects($this->never())->method('error'); |
72 | 75 | $class->setLogger($logger); |
73 | 76 | |
74 | - try { |
|
77 | + try |
|
78 | + { |
|
75 | 79 | $ref->invoke($class, 'foo'); |
76 | - } catch (LocatorException) { |
|
80 | + } |
|
81 | + catch (LocatorException) |
|
82 | + { |
|
77 | 83 | } |
78 | 84 | } |
79 | 85 | |
@@ -89,9 +95,12 @@ discard block |
||
89 | 95 | ); |
90 | 96 | $class->setLogger($logger); |
91 | 97 | |
92 | - try { |
|
98 | + try |
|
99 | + { |
|
93 | 100 | $ref->invoke($class, 'foo'); |
94 | - } catch (LocatorException) { |
|
101 | + } |
|
102 | + catch (LocatorException) |
|
103 | + { |
|
95 | 104 | } |
96 | 105 | } |
97 | 106 | |
@@ -104,14 +113,19 @@ discard block |
||
104 | 113 | $logger->expects($this->never())->method('error'); |
105 | 114 | $class->setLogger($logger); |
106 | 115 | |
107 | - try { |
|
116 | + try |
|
117 | + { |
|
108 | 118 | $ref->invoke($class, 'foo'); |
109 | - } catch (LocatorException) { |
|
119 | + } |
|
120 | + catch (LocatorException) |
|
121 | + { |
|
110 | 122 | } |
111 | 123 | } |
112 | 124 | |
113 | 125 | private function getLocator(bool $debug = false): AbstractLocator |
114 | 126 | { |
115 | - return new class($this->finder, $debug) extends AbstractLocator {}; |
|
127 | + return new class($this->finder, $debug) extends AbstractLocator |
|
128 | + { |
|
129 | +}; |
|
116 | 130 | } |
117 | 131 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | $this->container = new Container(); |
27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer([ |
28 | - 'scopes' => ['foo' => ['directories' => [__DIR__ . '/Enums/Inner'], 'exclude' => []]], |
|
28 | + 'scopes' => ['foo' => ['directories' => [__DIR__.'/Enums/Inner'], 'exclude' => []]], |
|
29 | 29 | ])); |
30 | 30 | $this->container->bindSingleton(ScopedEnumsInterface::class, ScopedEnumLocator::class); |
31 | 31 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | |
26 | 26 | $this->container = new Container(); |
27 | 27 | $this->container->bind(Tokenizer::class, $this->getTokenizer(['scopes' => [ |
28 | - 'foo' => ['directories' => [__DIR__ . '/Interfaces/Inner'], 'exclude' => []], |
|
28 | + 'foo' => ['directories' => [__DIR__.'/Interfaces/Inner'], 'exclude' => []], |
|
29 | 29 | ]])); |
30 | 30 | $this->container->bindSingleton(ScopedInterfacesInterface::class, ScopedInterfaceLocator::class); |
31 | 31 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)){ |
|
18 | 18 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 19 | } |
20 | 20 | } |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @throws InvalidArgumentException |
24 | 24 | */ |
25 | - public function serialize(mixed $payload): string|\Stringable |
|
25 | + public function serialize(mixed $payload): string | \Stringable |
|
26 | 26 | { |
27 | - if (!$payload instanceof Message) { |
|
27 | + if (!$payload instanceof Message){ |
|
28 | 28 | throw new InvalidArgumentException(\sprintf( |
29 | 29 | 'Payload must be of type `%s`, received `%s`.', |
30 | 30 | Message::class, |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * @throws UnserializeException |
40 | 40 | * @throws InvalidArgumentException |
41 | 41 | */ |
42 | - public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
|
42 | + public function unserialize(\Stringable | string $payload, object | string | null $type = null): mixed |
|
43 | 43 | { |
44 | - if (\is_object($type)) { |
|
44 | + if (\is_object($type)){ |
|
45 | 45 | $type = $type::class; |
46 | 46 | } |
47 | 47 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
48 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)){ |
|
49 | 49 | throw new InvalidArgumentException(\sprintf( |
50 | 50 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 51 | Message::class, |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | $object = new $type(); |
57 | 57 | |
58 | - try { |
|
59 | - $object->mergeFromString((string) $payload); |
|
60 | - } catch (\Throwable $e) { |
|
58 | + try{ |
|
59 | + $object->mergeFromString((string)$payload); |
|
60 | + }catch (\Throwable $e){ |
|
61 | 61 | throw new UnserializeException( |
62 | 62 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 63 | $e->getCode(), |
@@ -14,7 +14,8 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - if (!\class_exists(Message::class)) { |
|
17 | + if (!\class_exists(Message::class)) |
|
18 | + { |
|
18 | 19 | throw new SerializerException('Package `google/protobuf` is not installed.'); |
19 | 20 | } |
20 | 21 | } |
@@ -24,7 +25,8 @@ discard block |
||
24 | 25 | */ |
25 | 26 | public function serialize(mixed $payload): string|\Stringable |
26 | 27 | { |
27 | - if (!$payload instanceof Message) { |
|
28 | + if (!$payload instanceof Message) |
|
29 | + { |
|
28 | 30 | throw new InvalidArgumentException(\sprintf( |
29 | 31 | 'Payload must be of type `%s`, received `%s`.', |
30 | 32 | Message::class, |
@@ -41,11 +43,13 @@ discard block |
||
41 | 43 | */ |
42 | 44 | public function unserialize(\Stringable|string $payload, object|string|null $type = null): mixed |
43 | 45 | { |
44 | - if (\is_object($type)) { |
|
46 | + if (\is_object($type)) |
|
47 | + { |
|
45 | 48 | $type = $type::class; |
46 | 49 | } |
47 | 50 | |
48 | - if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) { |
|
51 | + if ($type === null || !\class_exists($type) || !\is_a($type, Message::class, true)) |
|
52 | + { |
|
49 | 53 | throw new InvalidArgumentException(\sprintf( |
50 | 54 | 'Parameter `$type` must be of type: `%s`, received `%s`.', |
51 | 55 | Message::class, |
@@ -55,9 +59,12 @@ discard block |
||
55 | 59 | |
56 | 60 | $object = new $type(); |
57 | 61 | |
58 | - try { |
|
62 | + try |
|
63 | + { |
|
59 | 64 | $object->mergeFromString((string) $payload); |
60 | - } catch (\Throwable $e) { |
|
65 | + } |
|
66 | + catch (\Throwable $e) |
|
67 | + { |
|
61 | 68 | throw new UnserializeException( |
62 | 69 | \sprintf('Failed to unserialize data: %s', $e->getMessage()), |
63 | 70 | $e->getCode(), |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | ->method('getArgument') |
38 | 38 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true); |
39 | 39 | |
40 | - $command = new #[AsCommand('foo')] class extends Command { |
|
40 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
41 | 41 | #[Argument] |
42 | 42 | public int $intVal; |
43 | 43 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | ->expects($this->never()) |
77 | 77 | ->method('getArgument'); |
78 | 78 | |
79 | - $command = new #[AsCommand('foo')] class extends Command { |
|
79 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
80 | 80 | #[Argument] |
81 | 81 | public int $arg; |
82 | 82 | }; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | ->method('getOption') |
100 | 100 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true, true); |
101 | 101 | |
102 | - $command = new #[AsCommand('foo')] class extends Command { |
|
102 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
103 | 103 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
104 | 104 | public int $intVal; |
105 | 105 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | ->method('getOption') |
143 | 143 | ->willReturnOnConsecutiveCalls(1, null, 0); |
144 | 144 | |
145 | - $command = new #[AsCommand('foo')] class extends Command { |
|
145 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
146 | 146 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
147 | 147 | public Status $required; |
148 | 148 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $input->expects($this->once())->method('hasOption')->willReturn(true); |
167 | 167 | $input->expects($this->once())->method('getOption')->willReturn('foo'); |
168 | 168 | |
169 | - $command = new #[AsCommand('foo')] class extends Command { |
|
169 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
170 | 170 | #[Option] |
171 | 171 | public Status $status; |
172 | 172 | }; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | ->expects($this->never()) |
189 | 189 | ->method('getOption'); |
190 | 190 | |
191 | - $command = new #[AsCommand('foo')] class extends Command { |
|
191 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
192 | 192 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
193 | 193 | public int $option; |
194 | 194 | }; |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | ->method('getOption') |
213 | 213 | ->willReturn(null); |
214 | 214 | |
215 | - $command = new #[AsCommand('foo')] class extends Command { |
|
215 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
216 | 216 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
217 | 217 | public int $option; |
218 | 218 | }; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | ->method('getOption') |
236 | 236 | ->willReturn(null); |
237 | 237 | |
238 | - $command = new #[AsCommand('foo')] class extends Command { |
|
238 | + $command = new #[AsCommand('foo')] class extends Command{ |
|
239 | 239 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
240 | 240 | public ?int $intVal; |
241 | 241 | }; |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | ->method('getArgument') |
38 | 38 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true); |
39 | 39 | |
40 | - $command = new #[AsCommand('foo')] class extends Command { |
|
40 | + $command = new #[AsCommand('foo')] class extends Command |
|
41 | + { |
|
41 | 42 | #[Argument] |
42 | 43 | public int $intVal; |
43 | 44 | |
@@ -76,7 +77,8 @@ discard block |
||
76 | 77 | ->expects($this->never()) |
77 | 78 | ->method('getArgument'); |
78 | 79 | |
79 | - $command = new #[AsCommand('foo')] class extends Command { |
|
80 | + $command = new #[AsCommand('foo')] class extends Command |
|
81 | + { |
|
80 | 82 | #[Argument] |
81 | 83 | public int $arg; |
82 | 84 | }; |
@@ -99,7 +101,8 @@ discard block |
||
99 | 101 | ->method('getOption') |
100 | 102 | ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true, true); |
101 | 103 | |
102 | - $command = new #[AsCommand('foo')] class extends Command { |
|
104 | + $command = new #[AsCommand('foo')] class extends Command |
|
105 | + { |
|
103 | 106 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
104 | 107 | public int $intVal; |
105 | 108 | |
@@ -142,7 +145,8 @@ discard block |
||
142 | 145 | ->method('getOption') |
143 | 146 | ->willReturnOnConsecutiveCalls(1, null, 0); |
144 | 147 | |
145 | - $command = new #[AsCommand('foo')] class extends Command { |
|
148 | + $command = new #[AsCommand('foo')] class extends Command |
|
149 | + { |
|
146 | 150 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
147 | 151 | public Status $required; |
148 | 152 | |
@@ -166,7 +170,8 @@ discard block |
||
166 | 170 | $input->expects($this->once())->method('hasOption')->willReturn(true); |
167 | 171 | $input->expects($this->once())->method('getOption')->willReturn('foo'); |
168 | 172 | |
169 | - $command = new #[AsCommand('foo')] class extends Command { |
|
173 | + $command = new #[AsCommand('foo')] class extends Command |
|
174 | + { |
|
170 | 175 | #[Option] |
171 | 176 | public Status $status; |
172 | 177 | }; |
@@ -188,7 +193,8 @@ discard block |
||
188 | 193 | ->expects($this->never()) |
189 | 194 | ->method('getOption'); |
190 | 195 | |
191 | - $command = new #[AsCommand('foo')] class extends Command { |
|
196 | + $command = new #[AsCommand('foo')] class extends Command |
|
197 | + { |
|
192 | 198 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
193 | 199 | public int $option; |
194 | 200 | }; |
@@ -212,7 +218,8 @@ discard block |
||
212 | 218 | ->method('getOption') |
213 | 219 | ->willReturn(null); |
214 | 220 | |
215 | - $command = new #[AsCommand('foo')] class extends Command { |
|
221 | + $command = new #[AsCommand('foo')] class extends Command |
|
222 | + { |
|
216 | 223 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
217 | 224 | public int $option; |
218 | 225 | }; |
@@ -235,7 +242,8 @@ discard block |
||
235 | 242 | ->method('getOption') |
236 | 243 | ->willReturn(null); |
237 | 244 | |
238 | - $command = new #[AsCommand('foo')] class extends Command { |
|
245 | + $command = new #[AsCommand('foo')] class extends Command |
|
246 | + { |
|
239 | 247 | #[Option(mode: InputOption::VALUE_REQUIRED)] |
240 | 248 | public ?int $intVal; |
241 | 249 | }; |
@@ -48,23 +48,23 @@ |
||
48 | 48 | |
49 | 49 | private function configureExtensions(ConsoleBootloader $console, ContainerInterface $container): void |
50 | 50 | { |
51 | - if ($container->has(TranslatorInterface::class)) { |
|
51 | + if ($container->has(TranslatorInterface::class)){ |
|
52 | 52 | $this->configureTranslator($console); |
53 | 53 | } |
54 | 54 | |
55 | - if ($container->has(ViewsInterface::class)) { |
|
55 | + if ($container->has(ViewsInterface::class)){ |
|
56 | 56 | $this->configureViews($console); |
57 | 57 | } |
58 | 58 | |
59 | - if ($container->has(EncryptionInterface::class)) { |
|
59 | + if ($container->has(EncryptionInterface::class)){ |
|
60 | 60 | $this->configureEncrypter($console); |
61 | 61 | } |
62 | 62 | |
63 | - if ($container->has(RouterInterface::class)) { |
|
63 | + if ($container->has(RouterInterface::class)){ |
|
64 | 64 | $console->addCommand(Router\ListCommand::class); |
65 | 65 | } |
66 | 66 | |
67 | - if ($container->has(ClassesInterface::class)) { |
|
67 | + if ($container->has(ClassesInterface::class)){ |
|
68 | 68 | $console->addCommand(Tokenizer\InfoCommand::class); |
69 | 69 | $console->addCommand(Tokenizer\ValidateCommand::class); |
70 | 70 | } |
@@ -48,23 +48,28 @@ |
||
48 | 48 | |
49 | 49 | private function configureExtensions(ConsoleBootloader $console, ContainerInterface $container): void |
50 | 50 | { |
51 | - if ($container->has(TranslatorInterface::class)) { |
|
51 | + if ($container->has(TranslatorInterface::class)) |
|
52 | + { |
|
52 | 53 | $this->configureTranslator($console); |
53 | 54 | } |
54 | 55 | |
55 | - if ($container->has(ViewsInterface::class)) { |
|
56 | + if ($container->has(ViewsInterface::class)) |
|
57 | + { |
|
56 | 58 | $this->configureViews($console); |
57 | 59 | } |
58 | 60 | |
59 | - if ($container->has(EncryptionInterface::class)) { |
|
61 | + if ($container->has(EncryptionInterface::class)) |
|
62 | + { |
|
60 | 63 | $this->configureEncrypter($console); |
61 | 64 | } |
62 | 65 | |
63 | - if ($container->has(RouterInterface::class)) { |
|
66 | + if ($container->has(RouterInterface::class)) |
|
67 | + { |
|
64 | 68 | $console->addCommand(Router\ListCommand::class); |
65 | 69 | } |
66 | 70 | |
67 | - if ($container->has(ClassesInterface::class)) { |
|
71 | + if ($container->has(ClassesInterface::class)) |
|
72 | + { |
|
68 | 73 | $console->addCommand(Tokenizer\InfoCommand::class); |
69 | 74 | $console->addCommand(Tokenizer\ValidateCommand::class); |
70 | 75 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | */ |
13 | 13 | class ExtendedContextInjector implements InjectorInterface |
14 | 14 | { |
15 | - public function createInjection(\ReflectionClass $class, \ReflectionParameter|string|null $context = null): object |
|
15 | + public function createInjection(\ReflectionClass $class, \ReflectionParameter | string | null $context = null): object |
|
16 | 16 | { |
17 | 17 | return (object)['context' => $context]; |
18 | 18 | } |
@@ -23,7 +23,8 @@ |
||
23 | 23 | $listeners = \method_exists($registry, 'getListenerClasses') ? $registry->getListenerClasses() : []; |
24 | 24 | |
25 | 25 | $grid = $this->table(['Listener', 'Suggestion']); |
26 | - foreach ($listeners as $class) { |
|
26 | + foreach ($listeners as $class) |
|
27 | + { |
|
27 | 28 | $ref = new \ReflectionClass($class); |
28 | 29 | $attribute = $reader->firstClassMetadata($ref, AbstractTarget::class); |
29 | 30 | $suggestion = match (true) { |
@@ -23,16 +23,16 @@ |
||
23 | 23 | $listeners = \method_exists($registry, 'getListenerClasses') ? $registry->getListenerClasses() : []; |
24 | 24 | |
25 | 25 | $grid = $this->table(['Listener', 'Suggestion']); |
26 | - foreach ($listeners as $class) { |
|
26 | + foreach ($listeners as $class){ |
|
27 | 27 | $ref = new \ReflectionClass($class); |
28 | 28 | $attribute = $reader->firstClassMetadata($ref, AbstractTarget::class); |
29 | 29 | $suggestion = match (true) { |
30 | - $attribute === null => 'Add <comment>#[TargetClass]</comment> or ' . |
|
30 | + $attribute === null => 'Add <comment>#[TargetClass]</comment> or '. |
|
31 | 31 | '<comment>#[TargetAttribute]</comment> attribute to the listener', |
32 | 32 | default => '<fg=green> ✓ </>', |
33 | 33 | }; |
34 | 34 | $grid->addRow([ |
35 | - $class . "\n" . \sprintf( |
|
35 | + $class."\n".\sprintf( |
|
36 | 36 | '<fg=gray>%s</>', |
37 | 37 | \str_replace([$dirs->get('root'), '\\'], ['', '/'], $ref->getFileName()), |
38 | 38 | ), |