Test Failed
Pull Request — master (#872)
by Maxim
08:44
created
src/Console/tests/Configurator/Attribute/FillPropertiesTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
             ->method('getArgument')
37 37
             ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true);
38 38
 
39
-        $command = new #[AsCommand('foo')] class extends Command {
39
+        $command = new #[AsCommand('foo')] class extends Command{
40 40
             #[Argument]
41 41
             public int $intVal;
42 42
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             ->expects($this->never())
76 76
             ->method('getArgument');
77 77
 
78
-        $command = new #[AsCommand('foo')] class extends Command {
78
+        $command = new #[AsCommand('foo')] class extends Command{
79 79
             #[Argument]
80 80
             public int $arg;
81 81
         };
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             ->method('getOption')
99 99
             ->willReturnOnConsecutiveCalls(5, 'foo', ['foo', 'bar'], 0.5, true, true);
100 100
 
101
-        $command = new #[AsCommand('foo')] class extends Command {
101
+        $command = new #[AsCommand('foo')] class extends Command{
102 102
             #[Option(mode: InputOption::VALUE_REQUIRED)]
103 103
             public int $intVal;
104 104
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             ->expects($this->never())
142 142
             ->method('getOption');
143 143
 
144
-        $command = new #[AsCommand('foo')] class extends Command {
144
+        $command = new #[AsCommand('foo')] class extends Command{
145 145
             #[Option(mode: InputOption::VALUE_REQUIRED)]
146 146
             public int $option;
147 147
         };
Please login to merge, or discard this patch.
src/Console/tests/Configurator/Attribute/OptionsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -234,7 +234,7 @@
 block discarded – undo
234 234
         $result = $this->parser->parse(new \ReflectionClass(
235 235
             new #[AsCommand(name: 'foo')] class {
236 236
                 #[Option(mode: InputOption::VALUE_OPTIONAL)]
237
-                private int|\stdClass $option;
237
+                private int | \stdClass $option;
238 238
             }
239 239
         ));
240 240
 
Please login to merge, or discard this patch.
src/Console/tests/Configurator/Attribute/ArgumentsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@
 block discarded – undo
182 182
         $result = $this->parser->parse(new \ReflectionClass(
183 183
             new #[AsCommand(name: 'foo')] class {
184 184
                 #[Argument]
185
-                private int|\stdClass $arg;
185
+                private int | \stdClass $arg;
186 186
             }
187 187
         ));
188 188
 
Please login to merge, or discard this patch.
src/Console/src/Attribute/AsCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
         public readonly string $name,
14 14
         public readonly ?string $description = null,
15 15
         public readonly ?string $help = null
16
-    ) {
16
+    ){
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
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 = InputOption::VALUE_NONE,
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/Attribute/Argument.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
     public function __construct(
18 18
         public readonly ?string $name = null,
19 19
         public readonly ?string $description = null,
20
-        public readonly \Closure|array $suggestedValues = [],
21
-    ) {
20
+        public readonly \Closure | array $suggestedValues = [],
21
+    ){
22 22
     }
23 23
 }
Please login to merge, or discard this patch.
src/Console/src/Attribute/Question.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,6 +13,6 @@
 block discarded – undo
13 13
     public function __construct(
14 14
         public readonly string $question,
15 15
         public readonly ?string $argument = null
16
-    ) {
16
+    ){
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
src/Console/src/Configurator/Attribute/Parser.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 {
24 24
     public function __construct(
25 25
         private readonly ReaderInterface $reader = new AttributeReader()
26
-    ) {
26
+    ){
27 27
     }
28 28
 
29 29
     public function hasCommandAttribute(\ReflectionClass $reflection): bool
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $reflection = new \ReflectionClass($command);
51 51
 
52
-        foreach ($reflection->getProperties() as $property) {
52
+        foreach ($reflection->getProperties() as $property){
53 53
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
54
-            if ($attribute === null) {
54
+            if ($attribute === null){
55 55
                 continue;
56 56
             }
57 57
 
58
-            if ($input->hasArgument($attribute->name ?? $property->getName())) {
58
+            if ($input->hasArgument($attribute->name ?? $property->getName())){
59 59
                 $property->setValue(
60 60
                     $command,
61 61
                     $this->typecast($input->getArgument($attribute->name ?? $property->getName()), $property)
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
             }
64 64
         }
65 65
 
66
-        foreach ($reflection->getProperties() as $property) {
66
+        foreach ($reflection->getProperties() as $property){
67 67
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
68
-            if ($attribute === null) {
68
+            if ($attribute === null){
69 69
                 continue;
70 70
             }
71 71
 
72
-            if ($input->hasOption($attribute->name ?? $property->getName())) {
72
+            if ($input->hasOption($attribute->name ?? $property->getName())){
73 73
                 $property->setValue(
74 74
                     $command,
75 75
                     $this->typecast($input->getOption($attribute->name ?? $property->getName()), $property)
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $result = [];
84 84
         $arrayArgument = null;
85
-        foreach ($reflection->getProperties() as $property) {
85
+        foreach ($reflection->getProperties() as $property){
86 86
             $attribute = $this->reader->firstPropertyMetadata($property, Argument::class);
87
-            if ($attribute === null) {
87
+            if ($attribute === null){
88 88
                 continue;
89 89
             }
90 90
 
@@ -102,24 +102,24 @@  discard block
 block discarded – undo
102 102
             $argument = new InputArgument(
103 103
                 name: $attribute->name ?? $property->getName(),
104 104
                 mode: $mode,
105
-                description: (string) $attribute->description,
105
+                description: (string)$attribute->description,
106 106
                 default: $property->hasDefaultValue() ? $property->getDefaultValue() : null,
107
-                suggestedValues: $attribute->suggestedValues
107
+                suggestedValues : $attribute->suggestedValues
108 108
             );
109 109
 
110
-            if ($arrayArgument !== null && $isArray) {
110
+            if ($arrayArgument !== null && $isArray){
111 111
                 throw new ConfiguratorException('There must be only one array argument!');
112 112
             }
113 113
 
114 114
             // It must be used at the end of the argument list.
115
-            if ($isArray) {
115
+            if ($isArray){
116 116
                 $arrayArgument = $argument;
117 117
                 continue;
118 118
             }
119 119
             $result[] = $argument;
120 120
         }
121 121
 
122
-        if ($arrayArgument !== null) {
122
+        if ($arrayArgument !== null){
123 123
             $result[] = $arrayArgument;
124 124
         }
125 125
 
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
     private function parseOptions(\ReflectionClass $reflection): array
130 130
     {
131 131
         $result = [];
132
-        foreach ($reflection->getProperties() as $property) {
132
+        foreach ($reflection->getProperties() as $property){
133 133
             $attribute = $this->reader->firstPropertyMetadata($property, Option::class);
134
-            if ($attribute === null) {
134
+            if ($attribute === null){
135 135
                 continue;
136 136
             }
137 137
 
138 138
             $type = $this->getPropertyType($property);
139 139
 
140
-            if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE) {
141
-                if ($type->getName() !== 'bool') {
140
+            if ($attribute->mode === InputOption::VALUE_NONE || $attribute->mode === InputOption::VALUE_NEGATABLE){
141
+                if ($type->getName() !== 'bool'){
142 142
                     throw new ConfiguratorException(
143 143
                         'Options properties with mode `VALUE_NONE` or `VALUE_NEGATABLE` must be bool!'
144 144
                     );
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
                 name: $attribute->name ?? $property->getName(),
152 152
                 shortcut: $attribute->shortcut,
153 153
                 mode: $attribute->mode,
154
-                description: (string) $attribute->description,
154
+                description: (string)$attribute->description,
155 155
                 default: $hasDefaultValue ? $property->getDefaultValue() : null,
156
-                suggestedValues: $attribute->suggestedValues
156
+                suggestedValues : $attribute->suggestedValues
157 157
             );
158 158
         }
159 159
 
@@ -164,23 +164,23 @@  discard block
 block discarded – undo
164 164
     {
165 165
         $type = $property->hasType() ? $property->getType() : null;
166 166
 
167
-        if (!$type instanceof \ReflectionNamedType) {
167
+        if (!$type instanceof \ReflectionNamedType){
168 168
             return $value;
169 169
         }
170 170
 
171 171
         return match ($type->getName()) {
172
-            'int' => (int) $value,
173
-            'string' => (string) $value,
174
-            'bool' => (bool) $value,
175
-            'float' => (float) $value,
176
-            'array' => (array) $value,
172
+            'int' => (int)$value,
173
+            'string' => (string)$value,
174
+            'bool' => (bool)$value,
175
+            'float' => (float)$value,
176
+            'array' => (array)$value,
177 177
             default => $value
178 178
         };
179 179
     }
180 180
 
181 181
     private function getPropertyType(\ReflectionProperty $property): \ReflectionNamedType
182 182
     {
183
-        if (!$property->hasType()) {
183
+        if (!$property->hasType()){
184 184
             throw new ConfiguratorException(
185 185
                 \sprintf('Please, specify the type for the `%s` property!', $property->getName())
186 186
             );
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 
189 189
         $type = $property->getType();
190 190
 
191
-        if ($type instanceof \ReflectionIntersectionType) {
191
+        if ($type instanceof \ReflectionIntersectionType){
192 192
             throw new ConfiguratorException(\sprintf('Invalid type for the `%s` property.', $property->getName()));
193 193
         }
194 194
 
195
-        if ($type instanceof \ReflectionUnionType) {
196
-            foreach ($type->getTypes() as $type) {
197
-                if ($type->isBuiltin()) {
195
+        if ($type instanceof \ReflectionUnionType){
196
+            foreach ($type->getTypes() as $type){
197
+                if ($type->isBuiltin()){
198 198
                     return $type;
199 199
                 }
200 200
             }
201 201
         }
202 202
 
203
-        if ($type instanceof \ReflectionNamedType && $type->isBuiltin()) {
203
+        if ($type instanceof \ReflectionNamedType && $type->isBuiltin()){
204 204
             return $type;
205 205
         }
206 206
 
Please login to merge, or discard this patch.
src/Console/src/Configurator/DefaultConfigurator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.