Test Failed
Pull Request — master (#902)
by butschster
24:40 queued 16:54
created
src/Scaffolder/src/Declaration/BootloaderDeclaration.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,8 @@
 block discarded – undo
41 41
         $this->class->addConstant('SINGLETONS', [])->setProtected();
42 42
         $this->class->addConstant('DEPENDENCIES', [])->setProtected();
43 43
 
44
-        if ($this->isDomain) {
44
+        if ($this->isDomain)
45
+        {
45 46
             $this->class->addConstant('INTERCEPTORS', [])->setProtected();
46 47
             $this->namespace->addUse(CoreInterface::class);
47 48
             $this->class->getConstant('SINGLETONS')->setValue([
Please login to merge, or discard this patch.
src/Scaffolder/tests/Command/CommandTest.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,8 @@
 block discarded – undo
24 24
             'alias' => $alias,
25 25
             '--description' => 'My sample command description',
26 26
         ];
27
-        if ($alias === null) {
27
+        if ($alias === null)
28
+        {
28 29
             unset($input['alias']);
29 30
         }
30 31
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/CommandCommand.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,11 +48,13 @@
 block discarded – undo
48 48
             'alias' => $this->alias ?? \strtolower(\preg_replace('/(?<!^)[A-Z]/', ':$0', $this->name)),
49 49
         ]);
50 50
 
51
-        foreach ($this->arguments as $argument) {
51
+        foreach ($this->arguments as $argument)
52
+        {
52 53
             $declaration->addArgument($argument);
53 54
         }
54 55
 
55
-        foreach ($this->options as $option) {
56
+        foreach ($this->options as $option)
57
+        {
56 58
             $declaration->addOption($option);
57 59
         }
58 60
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Declaration/CommandDeclaration.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,8 @@
 block discarded – undo
69 69
             'name' => $this->alias,
70 70
         ];
71 71
 
72
-        if ($this->description) {
72
+        if ($this->description)
73
+        {
73 74
             $commandDefinition['description'] = $this->description;
74 75
         }
75 76
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Declaration/ConfigDeclaration.php 1 patch
Braces   +35 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,8 +41,10 @@  discard block
 block discarded – undo
41 41
         $this->class->addConstant('CONFIG', $configName)->setPublic();
42 42
 
43 43
         $filename = $this->makeConfigFilename($configName);
44
-        if ($reverse) {
45
-            if (!$this->files->exists($filename)) {
44
+        if ($reverse)
45
+        {
46
+            if (!$this->files->exists($filename))
47
+            {
46 48
                 throw new ScaffolderException(\sprintf("Config filename %s doesn't exist", $filename));
47 49
             }
48 50
 
@@ -50,8 +52,11 @@  discard block
 block discarded – undo
50 52
             $this->declareGetters($defaultsFromFile);
51 53
 
52 54
             $this->class->getProperty('config')->setValue($this->defaultValues->get($defaultsFromFile));
53
-        } else {
54
-            if (!$this->files->exists($filename)) {
55
+        }
56
+        else
57
+        {
58
+            if (!$this->files->exists($filename))
59
+            {
55 60
                 $this->touchConfigFile($filename);
56 61
             }
57 62
         }
@@ -112,7 +117,8 @@  discard block
 block discarded – undo
112 117
         $getters = [];
113 118
         $gettersByKey = [];
114 119
 
115
-        foreach ($defaults as $key => $value) {
120
+        foreach ($defaults as $key => $value)
121
+        {
116 122
             $key = (string)$key;
117 123
             $getter = $this->makeGetterName($key);
118 124
             $getters[] = $getter;
@@ -120,19 +126,23 @@  discard block
 block discarded – undo
120 126
             $method = $this->class->addMethod($getter)->setPublic();
121 127
             $method->setBody(\sprintf('return $this->config[\'%s\'];', $key));
122 128
 
123
-            if (\is_array($value)) {
129
+            if (\is_array($value))
130
+            {
124 131
                 $gettersByKey[] = ['key' => $key, 'value' => $value];
125 132
             }
126 133
 
127 134
             $returnTypeHint = $this->typeHints->getHint(\gettype($value));
128
-            if ($returnTypeHint !== null) {
135
+            if ($returnTypeHint !== null)
136
+            {
129 137
                 $method->setReturnType($returnTypeHint);
130 138
             }
131 139
         }
132 140
 
133
-        foreach ($gettersByKey as $item) {
141
+        foreach ($gettersByKey as $item)
142
+        {
134 143
             $method = $this->declareGettersByKey($getters, $item['key'], $item['value']);
135
-            if ($method !== null) {
144
+            if ($method !== null)
145
+            {
136 146
                 $getters[] = $method->getName();
137 147
             }
138 148
         }
@@ -141,30 +151,35 @@  discard block
 block discarded – undo
141 151
     private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method
142 152
     {
143 153
         //Won't create if there's less than 2 sub-items
144
-        if (\count($value) < 2) {
154
+        if (\count($value) < 2)
155
+        {
145 156
             return null;
146 157
         }
147 158
 
148 159
         $singularKey = $this->singularize($key);
149 160
         $name = $this->makeGetterName($singularKey);
150
-        if (\in_array($name, $methodNames, true)) {
161
+        if (\in_array($name, $methodNames, true))
162
+        {
151 163
             $name = $this->makeGetterName($singularKey, 'get', 'by');
152 164
         }
153 165
 
154 166
         //Name conflict, won't merge
155
-        if (\in_array($name, $methodNames, true)) {
167
+        if (\in_array($name, $methodNames, true))
168
+        {
156 169
             return null;
157 170
         }
158 171
 
159 172
         $keyType = defineArrayType(\array_keys($value), '-mixed-');
160 173
         $valueType = defineArrayType(\array_values($value), '-mixed-');
161 174
         //We need a fixed structure here
162
-        if ($keyType === '-mixed-' || $valueType === '-mixed-') {
175
+        if ($keyType === '-mixed-' || $valueType === '-mixed-')
176
+        {
163 177
             return null;
164 178
         }
165 179
 
166 180
         //Won't create for associated arrays
167
-        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value)) {
181
+        if ($this->typeAnnotations->mapType($keyType) === 'int' && \array_is_list($value))
182
+        {
168 183
             return null;
169 184
         }
170 185
 
@@ -174,7 +189,8 @@  discard block
 block discarded – undo
174 189
 
175 190
         $param = $method->addParameter($singularKey);
176 191
         $paramTypeHint = $this->typeHints->getHint($keyType);
177
-        if ($paramTypeHint !== null) {
192
+        if ($paramTypeHint !== null)
193
+        {
178 194
             $param->setType($paramTypeHint);
179 195
         }
180 196
 
@@ -184,13 +200,15 @@  discard block
 block discarded – undo
184 200
     private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string
185 201
     {
186 202
         $chunks = [];
187
-        if (!empty($prefix)) {
203
+        if (!empty($prefix))
204
+        {
188 205
             $chunks[] = $prefix;
189 206
         }
190 207
 
191 208
         $name = $this->slugify->slugify($name, ['lowercase' => false]);
192 209
         $chunks[] = \count($chunks) !== 0 ? $this->classify($name) : $name;
193
-        if (!empty($postfix)) {
210
+        if (!empty($postfix))
211
+        {
194 212
             $chunks[] = \ucfirst($postfix);
195 213
         }
196 214
 
Please login to merge, or discard this patch.
src/Scaffolder/tests/Command/ConfigTest.php 1 patch
Braces   +13 added lines, -6 removed lines patch added patch discarded remove patch
@@ -137,17 +137,22 @@  discard block
 block discarded – undo
137 137
         ];
138 138
 
139 139
         $reflectionMethods = [];
140
-        foreach ($reflection->getMethods() as $method) {
141
-            if ($method->getDeclaringClass()->name !== $reflection->name) {
140
+        foreach ($reflection->getMethods() as $method)
141
+        {
142
+            if ($method->getDeclaringClass()->name !== $reflection->name)
143
+            {
142 144
                 continue;
143 145
             }
144 146
 
145 147
             $reflectionMethods[$method->name] = $method;
146 148
             $this->assertArrayHasKey($method->name, $methods);
147 149
 
148
-            if (!$method->hasReturnType()) {
150
+            if (!$method->hasReturnType())
151
+            {
149 152
                 $this->assertNull($methods[$method->name]['hint']);
150
-            } else {
153
+            }
154
+            else
155
+            {
151 156
                 $this->assertEquals($methods[$method->name]['hint'], $method->getReturnType()->getName());
152 157
             }
153 158
         }
@@ -189,8 +194,10 @@  discard block
 block discarded – undo
189 194
         ];
190 195
 
191 196
         $reflectionMethods = [];
192
-        foreach ($reflection->getMethods() as $method) {
193
-            if ($method->getDeclaringClass()->name !== $reflection->name) {
197
+        foreach ($reflection->getMethods() as $method)
198
+        {
199
+            if ($method->getDeclaringClass()->name !== $reflection->name)
200
+            {
194 201
                 continue;
195 202
             }
196 203
             $reflectionMethods[$method->name] = $method;
Please login to merge, or discard this patch.
src/Scaffolder/tests/Command/AbstractCommandTest.php 1 patch
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,11 +19,15 @@  discard block
 block discarded – undo
19 19
      */
20 20
     protected function deleteDeclaration(string $class): void
21 21
     {
22
-        if (class_exists($class)) {
23
-            try {
22
+        if (class_exists($class))
23
+        {
24
+            try
25
+            {
24 26
                 $reflection = new ReflectionClass($class);
25 27
                 $this->files()->delete($reflection->getFileName());
26
-            } catch (Throwable $exception) {
28
+            }
29
+            catch (Throwable $exception)
30
+            {
27 31
                 var_dump($exception->getMessage());
28 32
             }
29 33
         }
@@ -51,7 +55,8 @@  discard block
 block discarded – undo
51 55
     {
52 56
         parent::tearDown();
53 57
 
54
-        if ($this->className) {
58
+        if ($this->className)
59
+        {
55 60
             $this->deleteDeclaration($this->className);
56 61
         }
57 62
     }
Please login to merge, or discard this patch.
src/Scaffolder/src/Bootloader/ScaffolderBootloader.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,9 +39,12 @@
 block discarded – undo
39 39
         $console->addCommand(Command\MiddlewareCommand::class);
40 40
         $console->addCommand(Command\FilterCommand::class);
41 41
 
42
-        try {
42
+        try
43
+        {
43 44
             $defaultNamespace = (new ReflectionClass($this->kernel))->getNamespaceName();
44
-        } catch (ReflectionException) {
45
+        }
46
+        catch (ReflectionException)
47
+        {
45 48
             $defaultNamespace = '';
46 49
         }
47 50
 
Please login to merge, or discard this patch.
src/Scaffolder/src/Command/ControllerCommand.php 1 patch
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,11 +33,13 @@
 block discarded – undo
33 33
     {
34 34
         $declaration = $this->createDeclaration(ControllerDeclaration::class);
35 35
 
36
-        foreach ($this->actions as $action) {
36
+        foreach ($this->actions as $action)
37
+        {
37 38
             $declaration->addAction($action);
38 39
         }
39 40
 
40
-        if ($this->usePrototype) {
41
+        if ($this->usePrototype)
42
+        {
41 43
             $declaration->addPrototypeTrait();
42 44
         }
43 45
 
Please login to merge, or discard this patch.