@@ -41,7 +41,8 @@ |
||
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([ |
@@ -24,7 +24,8 @@ |
||
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 |
@@ -48,11 +48,13 @@ |
||
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 |
@@ -69,7 +69,8 @@ |
||
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 |
@@ -41,8 +41,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -137,17 +137,22 @@ discard block |
||
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 |
||
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; |