@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | public function __construct( |
26 | 26 | private readonly ReaderInterface $reader = new AttributeReader() |
27 | - ) { |
|
27 | + ){ |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function hasCommandAttribute(\ReflectionClass $reflection): bool |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $attribute = $this->reader->firstClassMetadata($reflection, AsCommand::class); |
39 | 39 | |
40 | - if ($attribute === null) { |
|
40 | + if ($attribute === null){ |
|
41 | 41 | $attribute = $reflection->getAttributes(SymfonyAsCommand::class)[0]->newInstance(); |
42 | 42 | } |
43 | 43 | |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | { |
55 | 55 | $reflection = new \ReflectionClass($command); |
56 | 56 | |
57 | - foreach ($reflection->getProperties() as $property) { |
|
57 | + foreach ($reflection->getProperties() as $property){ |
|
58 | 58 | $attribute = $this->reader->firstPropertyMetadata($property, Argument::class); |
59 | - if ($attribute === null) { |
|
59 | + if ($attribute === null){ |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
63 | - if ($input->hasArgument($attribute->name ?? $property->getName())) { |
|
63 | + if ($input->hasArgument($attribute->name ?? $property->getName())){ |
|
64 | 64 | $property->setValue( |
65 | 65 | $command, |
66 | 66 | $this->typecast($input->getArgument($attribute->name ?? $property->getName()), $property) |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | - foreach ($reflection->getProperties() as $property) { |
|
71 | + foreach ($reflection->getProperties() as $property){ |
|
72 | 72 | $attribute = $this->reader->firstPropertyMetadata($property, Option::class); |
73 | - if ($attribute === null) { |
|
73 | + if ($attribute === null){ |
|
74 | 74 | continue; |
75 | 75 | } |
76 | 76 | |
77 | - if ($input->hasOption($attribute->name ?? $property->getName())) { |
|
77 | + if ($input->hasOption($attribute->name ?? $property->getName())){ |
|
78 | 78 | $property->setValue( |
79 | 79 | $command, |
80 | 80 | $this->typecast($input->getOption($attribute->name ?? $property->getName()), $property) |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | { |
88 | 88 | $result = []; |
89 | 89 | $arrayArgument = null; |
90 | - foreach ($reflection->getProperties() as $property) { |
|
90 | + foreach ($reflection->getProperties() as $property){ |
|
91 | 91 | $attribute = $this->reader->firstPropertyMetadata($property, Argument::class); |
92 | - if ($attribute === null) { |
|
92 | + if ($attribute === null){ |
|
93 | 93 | continue; |
94 | 94 | } |
95 | 95 | |
@@ -107,24 +107,24 @@ discard block |
||
107 | 107 | $argument = new InputArgument( |
108 | 108 | name: $attribute->name ?? $property->getName(), |
109 | 109 | mode: $mode, |
110 | - description: (string) $attribute->description, |
|
110 | + description: (string)$attribute->description, |
|
111 | 111 | default: $property->hasDefaultValue() ? $property->getDefaultValue() : null, |
112 | - suggestedValues: $attribute->suggestedValues |
|
112 | + suggestedValues : $attribute->suggestedValues |
|
113 | 113 | ); |
114 | 114 | |
115 | - if ($arrayArgument !== null && $isArray) { |
|
115 | + if ($arrayArgument !== null && $isArray){ |
|
116 | 116 | throw new ConfiguratorException('There must be only one array argument!'); |
117 | 117 | } |
118 | 118 | |
119 | 119 | // It must be used at the end of the argument list. |
120 | - if ($isArray) { |
|
120 | + if ($isArray){ |
|
121 | 121 | $arrayArgument = $argument; |
122 | 122 | continue; |
123 | 123 | } |
124 | 124 | $result[] = $argument; |
125 | 125 | } |
126 | 126 | |
127 | - if ($arrayArgument !== null) { |
|
127 | + if ($arrayArgument !== null){ |
|
128 | 128 | $result[] = $arrayArgument; |
129 | 129 | } |
130 | 130 | |
@@ -134,16 +134,16 @@ discard block |
||
134 | 134 | private function parseOptions(\ReflectionClass $reflection): array |
135 | 135 | { |
136 | 136 | $result = []; |
137 | - foreach ($reflection->getProperties() as $property) { |
|
137 | + foreach ($reflection->getProperties() as $property){ |
|
138 | 138 | $attribute = $this->reader->firstPropertyMetadata($property, Option::class); |
139 | - if ($attribute === null) { |
|
139 | + if ($attribute === null){ |
|
140 | 140 | continue; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $type = $this->getPropertyType($property); |
144 | 144 | |
145 | - if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE) { |
|
146 | - if ($type->getName() !== 'bool') { |
|
145 | + if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE){ |
|
146 | + if ($type->getName() !== 'bool'){ |
|
147 | 147 | throw new ConfiguratorException( |
148 | 148 | 'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!' |
149 | 149 | ); |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | name: $attribute->name ?? $property->getName(), |
157 | 157 | shortcut: $attribute->shortcut, |
158 | 158 | mode: $attribute->mode, |
159 | - description: (string) $attribute->description, |
|
159 | + description: (string)$attribute->description, |
|
160 | 160 | default: $hasDefaultValue ? $property->getDefaultValue() : null, |
161 | - suggestedValues: $attribute->suggestedValues |
|
161 | + suggestedValues : $attribute->suggestedValues |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | |
@@ -169,23 +169,23 @@ discard block |
||
169 | 169 | { |
170 | 170 | $type = $property->hasType() ? $property->getType() : null; |
171 | 171 | |
172 | - if (!$type instanceof \ReflectionNamedType) { |
|
172 | + if (!$type instanceof \ReflectionNamedType){ |
|
173 | 173 | return $value; |
174 | 174 | } |
175 | 175 | |
176 | 176 | return match ($type->getName()) { |
177 | - 'int' => (int) $value, |
|
178 | - 'string' => (string) $value, |
|
179 | - 'bool' => (bool) $value, |
|
180 | - 'float' => (float) $value, |
|
181 | - 'array' => (array) $value, |
|
177 | + 'int' => (int)$value, |
|
178 | + 'string' => (string)$value, |
|
179 | + 'bool' => (bool)$value, |
|
180 | + 'float' => (float)$value, |
|
181 | + 'array' => (array)$value, |
|
182 | 182 | default => $value |
183 | 183 | }; |
184 | 184 | } |
185 | 185 | |
186 | 186 | private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType |
187 | 187 | { |
188 | - if (!$property->hasType()) { |
|
188 | + if (!$property->hasType()){ |
|
189 | 189 | throw new ConfiguratorException( |
190 | 190 | \sprintf('Please, specify the type for the `%s` property!', $property->getName()) |
191 | 191 | ); |
@@ -193,19 +193,19 @@ discard block |
||
193 | 193 | |
194 | 194 | $type = $property->getType(); |
195 | 195 | |
196 | - if ($type instanceof \ReflectionIntersectionType) { |
|
196 | + if ($type instanceof \ReflectionIntersectionType){ |
|
197 | 197 | throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName())); |
198 | 198 | } |
199 | 199 | |
200 | - if ($type instanceof \ReflectionUnionType) { |
|
201 | - foreach ($type->getTypes() as $type) { |
|
202 | - if ($type->isBuiltin()) { |
|
200 | + if ($type instanceof \ReflectionUnionType){ |
|
201 | + foreach ($type->getTypes() as $type){ |
|
202 | + if ($type->isBuiltin()){ |
|
203 | 203 | return $type; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) { |
|
208 | + if ($type instanceof \ReflectionNamedType && $type->isBuiltin()){ |
|
209 | 209 | return $type; |
210 | 210 | } |
211 | 211 |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | { |
38 | 38 | $attribute = $this->reader->firstClassMetadata($reflection, AsCommand::class); |
39 | 39 | |
40 | - if ($attribute === null) { |
|
40 | + if ($attribute === null) |
|
41 | + { |
|
41 | 42 | $attribute = $reflection->getAttributes(SymfonyAsCommand::class)[0]->newInstance(); |
42 | 43 | } |
43 | 44 | |
@@ -54,13 +55,16 @@ discard block |
||
54 | 55 | { |
55 | 56 | $reflection = new \ReflectionClass($command); |
56 | 57 | |
57 | - foreach ($reflection->getProperties() as $property) { |
|
58 | + foreach ($reflection->getProperties() as $property) |
|
59 | + { |
|
58 | 60 | $attribute = $this->reader->firstPropertyMetadata($property, Argument::class); |
59 | - if ($attribute === null) { |
|
61 | + if ($attribute === null) |
|
62 | + { |
|
60 | 63 | continue; |
61 | 64 | } |
62 | 65 | |
63 | - if ($input->hasArgument($attribute->name ?? $property->getName())) { |
|
66 | + if ($input->hasArgument($attribute->name ?? $property->getName())) |
|
67 | + { |
|
64 | 68 | $property->setValue( |
65 | 69 | $command, |
66 | 70 | $this->typecast($input->getArgument($attribute->name ?? $property->getName()), $property) |
@@ -68,13 +72,16 @@ discard block |
||
68 | 72 | } |
69 | 73 | } |
70 | 74 | |
71 | - foreach ($reflection->getProperties() as $property) { |
|
75 | + foreach ($reflection->getProperties() as $property) |
|
76 | + { |
|
72 | 77 | $attribute = $this->reader->firstPropertyMetadata($property, Option::class); |
73 | - if ($attribute === null) { |
|
78 | + if ($attribute === null) |
|
79 | + { |
|
74 | 80 | continue; |
75 | 81 | } |
76 | 82 | |
77 | - if ($input->hasOption($attribute->name ?? $property->getName())) { |
|
83 | + if ($input->hasOption($attribute->name ?? $property->getName())) |
|
84 | + { |
|
78 | 85 | $property->setValue( |
79 | 86 | $command, |
80 | 87 | $this->typecast($input->getOption($attribute->name ?? $property->getName()), $property) |
@@ -87,9 +94,11 @@ discard block |
||
87 | 94 | { |
88 | 95 | $result = []; |
89 | 96 | $arrayArgument = null; |
90 | - foreach ($reflection->getProperties() as $property) { |
|
97 | + foreach ($reflection->getProperties() as $property) |
|
98 | + { |
|
91 | 99 | $attribute = $this->reader->firstPropertyMetadata($property, Argument::class); |
92 | - if ($attribute === null) { |
|
100 | + if ($attribute === null) |
|
101 | + { |
|
93 | 102 | continue; |
94 | 103 | } |
95 | 104 | |
@@ -112,19 +121,22 @@ discard block |
||
112 | 121 | suggestedValues: $attribute->suggestedValues |
113 | 122 | ); |
114 | 123 | |
115 | - if ($arrayArgument !== null && $isArray) { |
|
124 | + if ($arrayArgument !== null && $isArray) |
|
125 | + { |
|
116 | 126 | throw new ConfiguratorException('There must be only one array argument!'); |
117 | 127 | } |
118 | 128 | |
119 | 129 | // It must be used at the end of the argument list. |
120 | - if ($isArray) { |
|
130 | + if ($isArray) |
|
131 | + { |
|
121 | 132 | $arrayArgument = $argument; |
122 | 133 | continue; |
123 | 134 | } |
124 | 135 | $result[] = $argument; |
125 | 136 | } |
126 | 137 | |
127 | - if ($arrayArgument !== null) { |
|
138 | + if ($arrayArgument !== null) |
|
139 | + { |
|
128 | 140 | $result[] = $arrayArgument; |
129 | 141 | } |
130 | 142 | |
@@ -134,16 +146,20 @@ discard block |
||
134 | 146 | private function parseOptions(\ReflectionClass $reflection): array |
135 | 147 | { |
136 | 148 | $result = []; |
137 | - foreach ($reflection->getProperties() as $property) { |
|
149 | + foreach ($reflection->getProperties() as $property) |
|
150 | + { |
|
138 | 151 | $attribute = $this->reader->firstPropertyMetadata($property, Option::class); |
139 | - if ($attribute === null) { |
|
152 | + if ($attribute === null) |
|
153 | + { |
|
140 | 154 | continue; |
141 | 155 | } |
142 | 156 | |
143 | 157 | $type = $this->getPropertyType($property); |
144 | 158 | |
145 | - if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE) { |
|
146 | - if ($type->getName() !== 'bool') { |
|
159 | + if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE) |
|
160 | + { |
|
161 | + if ($type->getName() !== 'bool') |
|
162 | + { |
|
147 | 163 | throw new ConfiguratorException( |
148 | 164 | 'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!' |
149 | 165 | ); |
@@ -169,7 +185,8 @@ discard block |
||
169 | 185 | { |
170 | 186 | $type = $property->hasType() ? $property->getType() : null; |
171 | 187 | |
172 | - if (!$type instanceof \ReflectionNamedType) { |
|
188 | + if (!$type instanceof \ReflectionNamedType) |
|
189 | + { |
|
173 | 190 | return $value; |
174 | 191 | } |
175 | 192 | |
@@ -185,7 +202,8 @@ discard block |
||
185 | 202 | |
186 | 203 | private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType |
187 | 204 | { |
188 | - if (!$property->hasType()) { |
|
205 | + if (!$property->hasType()) |
|
206 | + { |
|
189 | 207 | throw new ConfiguratorException( |
190 | 208 | \sprintf('Please, specify the type for the `%s` property!', $property->getName()) |
191 | 209 | ); |
@@ -193,19 +211,24 @@ discard block |
||
193 | 211 | |
194 | 212 | $type = $property->getType(); |
195 | 213 | |
196 | - if ($type instanceof \ReflectionIntersectionType) { |
|
214 | + if ($type instanceof \ReflectionIntersectionType) |
|
215 | + { |
|
197 | 216 | throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName())); |
198 | 217 | } |
199 | 218 | |
200 | - if ($type instanceof \ReflectionUnionType) { |
|
201 | - foreach ($type->getTypes() as $type) { |
|
202 | - if ($type->isBuiltin()) { |
|
219 | + if ($type instanceof \ReflectionUnionType) |
|
220 | + { |
|
221 | + foreach ($type->getTypes() as $type) |
|
222 | + { |
|
223 | + if ($type->isBuiltin()) |
|
224 | + { |
|
203 | 225 | return $type; |
204 | 226 | } |
205 | 227 | } |
206 | 228 | } |
207 | 229 | |
208 | - if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) { |
|
230 | + if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) |
|
231 | + { |
|
209 | 232 | return $type; |
210 | 233 | } |
211 | 234 |
@@ -24,13 +24,16 @@ discard block |
||
24 | 24 | { |
25 | 25 | $io = new SymfonyStyle($input, $output); |
26 | 26 | |
27 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
27 | + foreach ($command->getDefinition()->getArguments() as $argument) |
|
28 | + { |
|
28 | 29 | // Skip default argument "the command to execute" |
29 | - if ($argument->getName() === 'command') { |
|
30 | + if ($argument->getName() === 'command') |
|
31 | + { |
|
30 | 32 | continue; |
31 | 33 | } |
32 | 34 | |
33 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
35 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) |
|
36 | + { |
|
34 | 37 | $input->setArgument( |
35 | 38 | $argument->getName(), |
36 | 39 | $io->ask($this->getQuestion($command, $argument)) |
@@ -43,25 +46,31 @@ discard block |
||
43 | 46 | { |
44 | 47 | $reflection = new \ReflectionClass($command); |
45 | 48 | |
46 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
47 | - if ($question->argument === null) { |
|
49 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) |
|
50 | + { |
|
51 | + if ($question->argument === null) |
|
52 | + { |
|
48 | 53 | throw new ConsoleException( |
49 | 54 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
50 | 55 | ); |
51 | 56 | } |
52 | 57 | |
53 | - if ($argument->getName() === $question->argument) { |
|
58 | + if ($argument->getName() === $question->argument) |
|
59 | + { |
|
54 | 60 | return $question->question; |
55 | 61 | } |
56 | 62 | } |
57 | 63 | |
58 | - foreach ($reflection->getProperties() as $property) { |
|
64 | + foreach ($reflection->getProperties() as $property) |
|
65 | + { |
|
59 | 66 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
60 | - if ($question === null) { |
|
67 | + if ($question === null) |
|
68 | + { |
|
61 | 69 | continue; |
62 | 70 | } |
63 | 71 | |
64 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
72 | + if ($argument->getName() === ($question->argument ?? $property->getName())) |
|
73 | + { |
|
65 | 74 | return $question->question; |
66 | 75 | } |
67 | 76 | } |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | { |
21 | 21 | public function __construct( |
22 | 22 | private readonly ReaderInterface $reader = new AttributeReader() |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function promptMissedArguments(Command $command, InputInterface $input, OutputInterface $output): void |
27 | 27 | { |
28 | 28 | $io = new SymfonyStyle($input, $output); |
29 | 29 | |
30 | - foreach ($command->getDefinition()->getArguments() as $argument) { |
|
30 | + foreach ($command->getDefinition()->getArguments() as $argument){ |
|
31 | 31 | // Skip default argument "the command to execute" |
32 | - if ($argument->getName() === 'command') { |
|
32 | + if ($argument->getName() === 'command'){ |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | - if ($argument->isRequired() && $input->getArgument($argument->getName()) === null) { |
|
36 | + if ($argument->isRequired() && $input->getArgument($argument->getName()) === null){ |
|
37 | 37 | $input->setArgument( |
38 | 38 | $argument->getName(), |
39 | 39 | $io->ask($this->getQuestion($command, $argument)) |
@@ -46,25 +46,25 @@ discard block |
||
46 | 46 | { |
47 | 47 | $reflection = new \ReflectionClass($command); |
48 | 48 | |
49 | - foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question) { |
|
50 | - if ($question->argument === null) { |
|
49 | + foreach ($this->reader->getClassMetadata($reflection, Question::class) as $question){ |
|
50 | + if ($question->argument === null){ |
|
51 | 51 | throw new ConsoleException( |
52 | 52 | 'When using a `Question` attribute on a console command class, the argument parameter is required.' |
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | - if ($argument->getName() === $question->argument) { |
|
56 | + if ($argument->getName() === $question->argument){ |
|
57 | 57 | return $question->question; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - foreach ($reflection->getProperties() as $property) { |
|
61 | + foreach ($reflection->getProperties() as $property){ |
|
62 | 62 | $question = $this->reader->firstPropertyMetadata($property, Question::class); |
63 | - if ($question === null) { |
|
63 | + if ($question === null){ |
|
64 | 64 | continue; |
65 | 65 | } |
66 | 66 | |
67 | - if ($argument->getName() === ($question->argument ?? $property->getName())) { |
|
67 | + if ($argument->getName() === ($question->argument ?? $property->getName())){ |
|
68 | 68 | return $question->question; |
69 | 69 | } |
70 | 70 | } |
@@ -14,13 +14,13 @@ |
||
14 | 14 | public function configure(Command $command, \ReflectionClass $reflection): void |
15 | 15 | { |
16 | 16 | $command->setName($reflection->getConstant('NAME')); |
17 | - $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
|
17 | + $command->setDescription((string)$reflection->getConstant('DESCRIPTION')); |
|
18 | 18 | |
19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option){ |
|
20 | 20 | \call_user_func_array([$command, 'addOption'], $option); |
21 | 21 | } |
22 | 22 | |
23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
23 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument){ |
|
24 | 24 | \call_user_func_array([$command, 'addArgument'], $argument); |
25 | 25 | } |
26 | 26 | } |
@@ -16,11 +16,13 @@ |
||
16 | 16 | $command->setName($reflection->getConstant('NAME')); |
17 | 17 | $command->setDescription((string) $reflection->getConstant('DESCRIPTION')); |
18 | 18 | |
19 | - foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) { |
|
19 | + foreach ($reflection->getMethod('defineOptions')->invoke($command) as $option) |
|
20 | + { |
|
20 | 21 | \call_user_func_array([$command, 'addOption'], $option); |
21 | 22 | } |
22 | 23 | |
23 | - foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) { |
|
24 | + foreach ($reflection->getMethod('defineArguments')->invoke($command) as $argument) |
|
25 | + { |
|
24 | 26 | \call_user_func_array([$command, 'addArgument'], $argument); |
25 | 27 | } |
26 | 28 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly Parser $parser |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function canConfigure(Command $command, \ReflectionClass $reflection): bool |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | |
25 | 25 | public function configure(Command $command, \ReflectionClass $reflection): void |
26 | 26 | { |
27 | - $result = $this->parser->parse((string) $reflection->getConstant('SIGNATURE')); |
|
27 | + $result = $this->parser->parse((string)$reflection->getConstant('SIGNATURE')); |
|
28 | 28 | |
29 | 29 | $command->setName($result->name); |
30 | 30 | |
31 | - foreach ($result->options as $option) { |
|
31 | + foreach ($result->options as $option){ |
|
32 | 32 | $command->getDefinition()->addOption($option); |
33 | 33 | } |
34 | 34 | |
35 | - foreach ($result->arguments as $argument) { |
|
35 | + foreach ($result->arguments as $argument){ |
|
36 | 36 | $command->getDefinition()->addArgument($argument); |
37 | 37 | } |
38 | 38 | } |
@@ -28,11 +28,13 @@ |
||
28 | 28 | |
29 | 29 | $command->setName($result->name); |
30 | 30 | |
31 | - foreach ($result->options as $option) { |
|
31 | + foreach ($result->options as $option) |
|
32 | + { |
|
32 | 33 | $command->getDefinition()->addOption($option); |
33 | 34 | } |
34 | 35 | |
35 | - foreach ($result->arguments as $argument) { |
|
36 | + foreach ($result->arguments as $argument) |
|
37 | + { |
|
36 | 38 | $command->getDefinition()->addArgument($argument); |
37 | 39 | } |
38 | 40 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct( |
16 | 16 | private readonly Parser $parser |
17 | - ) { |
|
17 | + ){ |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function canConfigure(Command $command, \ReflectionClass $reflection): bool |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | $result = $this->parser->parse($reflection); |
28 | 28 | |
29 | 29 | $command->setName($result->name); |
30 | - $command->setDescription((string) $result->description); |
|
31 | - $command->setHelp((string) $result->help); |
|
30 | + $command->setDescription((string)$result->description); |
|
31 | + $command->setHelp((string)$result->help); |
|
32 | 32 | |
33 | - foreach ($result->options as $option) { |
|
33 | + foreach ($result->options as $option){ |
|
34 | 34 | $command->getDefinition()->addOption($option); |
35 | 35 | } |
36 | 36 | |
37 | - foreach ($result->arguments as $argument) { |
|
37 | + foreach ($result->arguments as $argument){ |
|
38 | 38 | $command->getDefinition()->addArgument($argument); |
39 | 39 | } |
40 | 40 | } |
@@ -30,11 +30,13 @@ |
||
30 | 30 | $command->setDescription((string) $result->description); |
31 | 31 | $command->setHelp((string) $result->help); |
32 | 32 | |
33 | - foreach ($result->options as $option) { |
|
33 | + foreach ($result->options as $option) |
|
34 | + { |
|
34 | 35 | $command->getDefinition()->addOption($option); |
35 | 36 | } |
36 | 37 | |
37 | - foreach ($result->arguments as $argument) { |
|
38 | + foreach ($result->arguments as $argument) |
|
39 | + { |
|
38 | 40 | $command->getDefinition()->addArgument($argument); |
39 | 41 | } |
40 | 42 | } |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
32 | 32 | |
33 | - foreach ($classes as $class) { |
|
33 | + foreach ($classes as $class){ |
|
34 | 34 | $listener->shouldReceive('listen') |
35 | 35 | ->once() |
36 | 36 | ->with($class); |
@@ -30,7 +30,8 @@ |
||
30 | 30 | |
31 | 31 | $listener = \Mockery::mock(TokenizationListenerInterface::class); |
32 | 32 | |
33 | - foreach ($classes as $class) { |
|
33 | + foreach ($classes as $class) |
|
34 | + { |
|
34 | 35 | $listener->shouldReceive('listen') |
35 | 36 | ->once() |
36 | 37 | ->with($class); |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | use MockeryPHPUnitIntegration; |
22 | 22 | |
23 | 23 | private ClassLocatorByDefinition $locator; |
24 | - private ClassesInterface|m\LegacyMockInterface|m\MockInterface $classes; |
|
25 | - private ScopedClassesInterface|m\LegacyMockInterface|m\MockInterface $scopedClasses; |
|
24 | + private ClassesInterface | m\LegacyMockInterface | m\MockInterface $classes; |
|
25 | + private ScopedClassesInterface | m\LegacyMockInterface | m\MockInterface $scopedClasses; |
|
26 | 26 | |
27 | 27 | protected function setUp(): void |
28 | 28 | { |
@@ -106,11 +106,11 @@ discard block |
||
106 | 106 | $definition = \iterator_to_array((new AttributesParser(new AttributeReader())) |
107 | 107 | ->parse(new $listener))[0]; |
108 | 108 | |
109 | - if ($definition->getScope() === null) { |
|
109 | + if ($definition->getScope() === null){ |
|
110 | 110 | $this->classes |
111 | 111 | ->shouldReceive('getClasses') |
112 | 112 | ->andReturn($classes); |
113 | - } else { |
|
113 | + }else{ |
|
114 | 114 | $this->scopedClasses |
115 | 115 | ->shouldReceive('getScopedClasses') |
116 | 116 | ->with($definition->getScope()) |
@@ -106,11 +106,14 @@ |
||
106 | 106 | $definition = \iterator_to_array((new AttributesParser(new AttributeReader())) |
107 | 107 | ->parse(new $listener))[0]; |
108 | 108 | |
109 | - if ($definition->getScope() === null) { |
|
109 | + if ($definition->getScope() === null) |
|
110 | + { |
|
110 | 111 | $this->classes |
111 | 112 | ->shouldReceive('getClasses') |
112 | 113 | ->andReturn($classes); |
113 | - } else { |
|
114 | + } |
|
115 | + else |
|
116 | + { |
|
114 | 117 | $this->scopedClasses |
115 | 118 | ->shouldReceive('getScopedClasses') |
116 | 119 | ->with($definition->getScope()) |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $env = m::mock(EnvironmentInterface::class); |
60 | 60 | $env->shouldReceive('get')->with('TOKENIZER_WARMUP', false)->andReturnTrue(); |
61 | 61 | |
62 | - $config = new TokenizerConfig(['cache' => ['directory' => 'cache',]]); |
|
62 | + $config = new TokenizerConfig(['cache' => ['directory' => 'cache', ]]); |
|
63 | 63 | |
64 | 64 | $this->assertSame( |
65 | 65 | $loader, |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | public function __construct( |
17 | 17 | private readonly ReaderInterface $reader, |
18 | - ) { |
|
18 | + ){ |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | { |
26 | 26 | $listener = new \ReflectionClass($listener); |
27 | 27 | |
28 | - foreach ($this->reader->getClassMetadata($listener) as $attribute) { |
|
29 | - if ($attribute instanceof ListenerDefinitionInterface) { |
|
28 | + foreach ($this->reader->getClassMetadata($listener) as $attribute){ |
|
29 | + if ($attribute instanceof ListenerDefinitionInterface){ |
|
30 | 30 | yield $attribute; |
31 | 31 | } |
32 | 32 | } |
@@ -25,8 +25,10 @@ |
||
25 | 25 | { |
26 | 26 | $listener = new \ReflectionClass($listener); |
27 | 27 | |
28 | - foreach ($this->reader->getClassMetadata($listener) as $attribute) { |
|
29 | - if ($attribute instanceof ListenerDefinitionInterface) { |
|
28 | + foreach ($this->reader->getClassMetadata($listener) as $attribute) |
|
29 | + { |
|
30 | + if ($attribute instanceof ListenerDefinitionInterface) |
|
31 | + { |
|
30 | 32 | yield $attribute; |
31 | 33 | } |
32 | 34 | } |