Test Failed
Pull Request — master (#893)
by Maxim
18:07
created
src/Console/src/Attribute/Option.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@
 block discarded – undo
19 19
      */
20 20
     public function __construct(
21 21
         public readonly ?string $name = null,
22
-        public readonly string|array|null $shortcut = null,
22
+        public readonly string | array | null $shortcut = null,
23 23
         public readonly ?string $description = null,
24 24
         public readonly ?int $mode = null,
25
-        public readonly \Closure|array $suggestedValues = []
26
-    ) {
25
+        public readonly \Closure | array $suggestedValues = []
26
+    ){
27 27
     }
28 28
 }
Please login to merge, or discard this patch.
src/Console/src/Configurator/Attribute/Parser.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,21 +134,21 @@  discard block
 block discarded – undo
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
             $mode = $attribute->mode;
145 145
 
146
-            if ($mode === null) {
146
+            if ($mode === null){
147 147
                 $mode = $this->guessOptionMode($type, $property);
148 148
             }
149 149
 
150
-            if ($mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE) {
151
-                if ($type->getName() !== 'bool') {
150
+            if ($mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE){
151
+                if ($type->getName() !== 'bool'){
152 152
                     throw new ConfiguratorException(
153 153
                         'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!'
154 154
                     );
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
                 name: $attribute->name ?? $property->getName(),
162 162
                 shortcut: $attribute->shortcut,
163 163
                 mode: $mode,
164
-                description: (string) $attribute->description,
164
+                description: (string)$attribute->description,
165 165
                 default: $hasDefaultValue ? $property->getDefaultValue() : null,
166
-                suggestedValues: $attribute->suggestedValues
166
+                suggestedValues : $attribute->suggestedValues
167 167
             );
168 168
         }
169 169
 
@@ -174,23 +174,23 @@  discard block
 block discarded – undo
174 174
     {
175 175
         $type = $property->hasType() ? $property->getType() : null;
176 176
 
177
-        if (!$type instanceof \ReflectionNamedType) {
177
+        if (!$type instanceof \ReflectionNamedType){
178 178
             return $value;
179 179
         }
180 180
 
181 181
         return match ($type->getName()) {
182
-            'int' => (int) $value,
183
-            'string' => (string) $value,
184
-            'bool' => (bool) $value,
185
-            'float' => (float) $value,
186
-            'array' => (array) $value,
182
+            'int' => (int)$value,
183
+            'string' => (string)$value,
184
+            'bool' => (bool)$value,
185
+            'float' => (float)$value,
186
+            'array' => (array)$value,
187 187
             default => $value
188 188
         };
189 189
     }
190 190
 
191 191
     private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType
192 192
     {
193
-        if (!$property->hasType()) {
193
+        if (!$property->hasType()){
194 194
             throw new ConfiguratorException(
195 195
                 \sprintf('Please, specify the type for the `%s` property!', $property->getName())
196 196
             );
@@ -198,19 +198,19 @@  discard block
 block discarded – undo
198 198
 
199 199
         $type = $property->getType();
200 200
 
201
-        if ($type instanceof \ReflectionIntersectionType) {
201
+        if ($type instanceof \ReflectionIntersectionType){
202 202
             throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName()));
203 203
         }
204 204
 
205
-        if ($type instanceof \ReflectionUnionType) {
206
-            foreach ($type->getTypes() as $type) {
207
-                if ($type->isBuiltin()) {
205
+        if ($type instanceof \ReflectionUnionType){
206
+            foreach ($type->getTypes() as $type){
207
+                if ($type->isBuiltin()){
208 208
                     return $type;
209 209
                 }
210 210
             }
211 211
         }
212 212
 
213
-        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object') {
213
+        if ($type instanceof \ReflectionNamedType && $type->isBuiltin() && $type->getName() !== 'object'){
214 214
             return $type;
215 215
         }
216 216
 
Please login to merge, or discard this patch.