@@ -54,11 +54,11 @@ |
||
54 | 54 | /** @var ControllerDeclaration $declaration */ |
55 | 55 | $declaration = $this->createDeclaration(); |
56 | 56 | |
57 | - foreach ($this->option('action') as $action) { |
|
57 | + foreach ($this->option('action') as $action){ |
|
58 | 58 | $declaration->addAction($action); |
59 | 59 | } |
60 | 60 | |
61 | - if ((bool)$this->option('prototype')) { |
|
61 | + if ((bool)$this->option('prototype')){ |
|
62 | 62 | $declaration->addPrototypeTrait(); |
63 | 63 | } |
64 | 64 |
@@ -54,11 +54,13 @@ |
||
54 | 54 | /** @var ControllerDeclaration $declaration */ |
55 | 55 | $declaration = $this->createDeclaration(); |
56 | 56 | |
57 | - foreach ($this->option('action') as $action) { |
|
57 | + foreach ($this->option('action') as $action) |
|
58 | + { |
|
58 | 59 | $declaration->addAction($action); |
59 | 60 | } |
60 | 61 | |
61 | - if ((bool)$this->option('prototype')) { |
|
62 | + if ((bool)$this->option('prototype')) |
|
63 | + { |
|
62 | 64 | $declaration->addPrototypeTrait(); |
63 | 65 | } |
64 | 66 |
@@ -60,10 +60,10 @@ |
||
60 | 60 | /** @var MigrationDeclaration $declaration */ |
61 | 61 | $declaration = $this->createDeclaration(); |
62 | 62 | |
63 | - if (!empty($this->option('table'))) { |
|
63 | + if (!empty($this->option('table'))){ |
|
64 | 64 | $fields = []; |
65 | - foreach ($this->option('field') as $field) { |
|
66 | - if (strpos($field, ':') === false) { |
|
65 | + foreach ($this->option('field') as $field){ |
|
66 | + if (strpos($field, ':') === false){ |
|
67 | 67 | throw new ScaffolderException("Field definition must in 'name:type' form"); |
68 | 68 | } |
69 | 69 |
@@ -60,10 +60,13 @@ |
||
60 | 60 | /** @var MigrationDeclaration $declaration */ |
61 | 61 | $declaration = $this->createDeclaration(); |
62 | 62 | |
63 | - if (!empty($this->option('table'))) { |
|
63 | + if (!empty($this->option('table'))) |
|
64 | + { |
|
64 | 65 | $fields = []; |
65 | - foreach ($this->option('field') as $field) { |
|
66 | - if (strpos($field, ':') === false) { |
|
66 | + foreach ($this->option('field') as $field) |
|
67 | + { |
|
68 | + if (strpos($field, ':') === false) |
|
69 | + { |
|
67 | 70 | throw new ScaffolderException("Field definition must in 'name:type' form"); |
68 | 71 | } |
69 | 72 |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | FilesInterface $files, |
52 | 52 | ContainerInterface $container, |
53 | 53 | FactoryInterface $factory |
54 | - ) { |
|
54 | + ){ |
|
55 | 55 | $this->config = $config; |
56 | 56 | $this->files = $files; |
57 | 57 | $this->factory = $factory; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $filename = $this->config->classFilename($type, (string)$this->argument('name')); |
111 | 111 | $filename = $this->files->normalizePath($filename); |
112 | 112 | |
113 | - if ($this->files->exists($filename)) { |
|
113 | + if ($this->files->exists($filename)){ |
|
114 | 114 | $this->writeln( |
115 | 115 | "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " |
116 | 116 | . "file '<comment>{$filename}</comment>' already exists.</fg=red>" |
@@ -110,7 +110,8 @@ |
||
110 | 110 | $filename = $this->config->classFilename($type, (string)$this->argument('name')); |
111 | 111 | $filename = $this->files->normalizePath($filename); |
112 | 112 | |
113 | - if ($this->files->exists($filename)) { |
|
113 | + if ($this->files->exists($filename)) |
|
114 | + { |
|
114 | 115 | $this->writeln( |
115 | 116 | "<fg=red>Unable to create '<comment>{$declaration->getName()}</comment>' declaration, " |
116 | 117 | . "file '<comment>{$filename}</comment>' already exists.</fg=red>" |
@@ -114,7 +114,7 @@ |
||
114 | 114 | $this->files->write( |
115 | 115 | $filename, |
116 | 116 | $file->render(), |
117 | - FilesInterface::READONLY, |
|
117 | + FilesInterface::readonly, |
|
118 | 118 | true |
119 | 119 | ); |
120 | 120 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | ['name', InputArgument::REQUIRED, 'Command name'], |
27 | 27 | ['alias', InputArgument::OPTIONAL, 'Command id/alias'], |
28 | 28 | ]; |
29 | - protected const OPTIONS = [ |
|
29 | + protected const OPTIONS = [ |
|
30 | 30 | [ |
31 | 31 | 'description', |
32 | 32 | 'd', |
@@ -69,11 +69,13 @@ discard block |
||
69 | 69 | $localNamespace = trim($this->getOption($element, 'namespace', ''), '\\'); |
70 | 70 | ['namespace' => $namespace] = $this->parseName($name); |
71 | 71 | |
72 | - if (!empty($namespace)) { |
|
72 | + if (!empty($namespace)) |
|
73 | + { |
|
73 | 74 | $localNamespace .= '\\' . $this->classify($namespace); |
74 | 75 | } |
75 | 76 | |
76 | - if (empty($this->baseNamespace())) { |
|
77 | + if (empty($this->baseNamespace())) |
|
78 | + { |
|
77 | 79 | return $localNamespace; |
78 | 80 | } |
79 | 81 | |
@@ -106,7 +108,8 @@ discard block |
||
106 | 108 | { |
107 | 109 | $class = $this->getOption($element, 'class'); |
108 | 110 | |
109 | - if (empty($class)) { |
|
111 | + if (empty($class)) |
|
112 | + { |
|
110 | 113 | throw new ScaffolderException( |
111 | 114 | "Unable to scaffold '{$element}', no declaration class found" |
112 | 115 | ); |
@@ -143,11 +146,13 @@ discard block |
||
143 | 146 | */ |
144 | 147 | private function getOption(string $element, string $section, $default = null) |
145 | 148 | { |
146 | - if (!isset($this->config['declarations'][$element])) { |
|
149 | + if (!isset($this->config['declarations'][$element])) |
|
150 | + { |
|
147 | 151 | throw new ScaffolderException("Undefined declaration '{$element}'."); |
148 | 152 | } |
149 | 153 | |
150 | - if (array_key_exists($section, $this->config['declarations'][$element])) { |
|
154 | + if (array_key_exists($section, $this->config['declarations'][$element])) |
|
155 | + { |
|
151 | 156 | return $this->config['declarations'][$element][$section]; |
152 | 157 | } |
153 | 158 | |
@@ -164,7 +169,8 @@ discard block |
||
164 | 169 | { |
165 | 170 | $name = str_replace('/', '\\', $name); |
166 | 171 | |
167 | - if (strpos($name, '\\') !== false) { |
|
172 | + if (strpos($name, '\\') !== false) |
|
173 | + { |
|
168 | 174 | $names = explode('\\', $name); |
169 | 175 | $class = array_pop($names); |
170 | 176 | |
@@ -192,11 +198,15 @@ discard block |
||
192 | 198 | { |
193 | 199 | $firstChunkIterated = false; |
194 | 200 | $joinedPath = ''; |
195 | - foreach ($chunks as $chunk) { |
|
196 | - if (!$firstChunkIterated) { |
|
201 | + foreach ($chunks as $chunk) |
|
202 | + { |
|
203 | + if (!$firstChunkIterated) |
|
204 | + { |
|
197 | 205 | $firstChunkIterated = true; |
198 | 206 | $joinedPath = $chunk; |
199 | - } else { |
|
207 | + } |
|
208 | + else |
|
209 | + { |
|
200 | 210 | $joinedPath = rtrim($joinedPath, $joint) . $joint . ltrim($chunk, $joint); |
201 | 211 | } |
202 | 212 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | { |
46 | 46 | ['name' => $name] = $this->parseName($name); |
47 | 47 | |
48 | - return $this->classify($name) . $this->elementPostfix($element); |
|
48 | + return $this->classify($name).$this->elementPostfix($element); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | public function classNamespace(string $element, string $name = ''): string |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | $localNamespace = trim($this->getOption($element, 'namespace', ''), '\\'); |
54 | 54 | ['namespace' => $namespace] = $this->parseName($name); |
55 | 55 | |
56 | - if (!empty($namespace)) { |
|
57 | - $localNamespace .= '\\' . $this->classify($namespace); |
|
56 | + if (!empty($namespace)){ |
|
57 | + $localNamespace .= '\\'.$this->classify($namespace); |
|
58 | 58 | } |
59 | 59 | |
60 | - if (empty($this->baseNamespace())) { |
|
60 | + if (empty($this->baseNamespace())){ |
|
61 | 61 | return $localNamespace; |
62 | 62 | } |
63 | 63 | |
64 | - return trim($this->baseNamespace() . '\\' . $localNamespace, '\\'); |
|
64 | + return trim($this->baseNamespace().'\\'.$localNamespace, '\\'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function classFilename(string $element, string $name): string |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | return $this->joinPathChunks([ |
73 | 73 | $this->baseDirectory(), |
74 | 74 | str_replace('\\', '/', $namespace), |
75 | - $this->className($element, $name) . '.php', |
|
75 | + $this->className($element, $name).'.php', |
|
76 | 76 | ], '/'); |
77 | 77 | } |
78 | 78 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | { |
84 | 84 | $class = $this->getOption($element, 'class'); |
85 | 85 | |
86 | - if (empty($class)) { |
|
86 | + if (empty($class)){ |
|
87 | 87 | throw new ScaffolderException( |
88 | 88 | "Unable to scaffold '{$element}', no declaration class found" |
89 | 89 | ); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | */ |
112 | 112 | private function getOption(string $element, string $section, $default = null) |
113 | 113 | { |
114 | - if (!isset($this->config['declarations'][$element])) { |
|
114 | + if (!isset($this->config['declarations'][$element])){ |
|
115 | 115 | throw new ScaffolderException("Undefined declaration '{$element}'."); |
116 | 116 | } |
117 | 117 | |
118 | - if (array_key_exists($section, $this->config['declarations'][$element])) { |
|
118 | + if (array_key_exists($section, $this->config['declarations'][$element])){ |
|
119 | 119 | return $this->config['declarations'][$element][$section]; |
120 | 120 | } |
121 | 121 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | { |
132 | 132 | $name = str_replace('/', '\\', $name); |
133 | 133 | |
134 | - if (strpos($name, '\\') !== false) { |
|
134 | + if (strpos($name, '\\') !== false){ |
|
135 | 135 | $names = explode('\\', $name); |
136 | 136 | $class = array_pop($names); |
137 | 137 | |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | { |
152 | 152 | $firstChunkIterated = false; |
153 | 153 | $joinedPath = ''; |
154 | - foreach ($chunks as $chunk) { |
|
155 | - if (!$firstChunkIterated) { |
|
154 | + foreach ($chunks as $chunk){ |
|
155 | + if (!$firstChunkIterated){ |
|
156 | 156 | $firstChunkIterated = true; |
157 | 157 | $joinedPath = $chunk; |
158 | - } else { |
|
159 | - $joinedPath = rtrim($joinedPath, $joint) . $joint . ltrim($chunk, $joint); |
|
158 | + }else{ |
|
159 | + $joinedPath = rtrim($joinedPath, $joint).$joint.ltrim($chunk, $joint); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | private function classify(string $name): string |
167 | 167 | { |
168 | - return ( new InflectorFactory() ) |
|
168 | + return (new InflectorFactory()) |
|
169 | 169 | ->build() |
170 | 170 | ->classify($name); |
171 | 171 | } |
@@ -96,11 +96,13 @@ |
||
96 | 96 | { |
97 | 97 | $property = $this->property($name); |
98 | 98 | $property->setComment("@var {$this->variableType($type)}"); |
99 | - if ($accessibility) { |
|
99 | + if ($accessibility) |
|
100 | + { |
|
100 | 101 | $property->setAccess($accessibility); |
101 | 102 | } |
102 | 103 | |
103 | - if ($property->getAccess() !== self::ACCESS_PUBLIC) { |
|
104 | + if ($property->getAccess() !== self::ACCESS_PUBLIC) |
|
105 | + { |
|
104 | 106 | $this->declareAccessors($name, $type); |
105 | 107 | } |
106 | 108 |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | { |
77 | 77 | $property = $this->property($name); |
78 | 78 | $property->setComment("@var {$this->variableType($type)}"); |
79 | - if ($accessibility) { |
|
79 | + if ($accessibility){ |
|
80 | 80 | $property->setAccess($accessibility); |
81 | 81 | } |
82 | 82 | |
83 | - if ($property->getAccess() !== self::ACCESS_PUBLIC) { |
|
83 | + if ($property->getAccess() !== self::ACCESS_PUBLIC){ |
|
84 | 84 | $this->declareAccessors($name, $type); |
85 | 85 | } |
86 | 86 | |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | |
97 | 97 | private function variableType(string $type): string |
98 | 98 | { |
99 | - return $this->isNullableType($type) ? (substr($type, 1) . '|null') : $type; |
|
99 | + return $this->isNullableType($type) ? (substr($type, 1).'|null') : $type; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | private function declareAccessors(string $field, string $type): void |
103 | 103 | { |
104 | - $setter = $this->method('set' . $this->classify($field)); |
|
104 | + $setter = $this->method('set'.$this->classify($field)); |
|
105 | 105 | $setter->setPublic(); |
106 | 106 | $setter->parameter('value')->setType($type); |
107 | 107 | $setter->setSource("\$this->$field = \$value;"); |
108 | 108 | |
109 | - $getter = $this->method('get' . $this->classify($field)); |
|
109 | + $getter = $this->method('get'.$this->classify($field)); |
|
110 | 110 | $getter->setPublic(); |
111 | 111 | $getter->setSource("return \$this->$field;"); |
112 | 112 | } |
113 | 113 | |
114 | 114 | private function classify(string $name): string |
115 | 115 | { |
116 | - return ( new InflectorFactory() ) |
|
116 | + return (new InflectorFactory()) |
|
117 | 117 | ->build() |
118 | 118 | ->classify($name); |
119 | 119 | } |
@@ -102,16 +102,21 @@ discard block |
||
102 | 102 | public function create(bool $reverse): void |
103 | 103 | { |
104 | 104 | $filename = $this->makeConfigFilename($this->configName); |
105 | - if ($reverse) { |
|
106 | - if (!$this->files->exists($filename)) { |
|
105 | + if ($reverse) |
|
106 | + { |
|
107 | + if (!$this->files->exists($filename)) |
|
108 | + { |
|
107 | 109 | throw new ScaffolderException("Config filename $filename doesn't exist"); |
108 | 110 | } |
109 | 111 | |
110 | 112 | $defaultsFromFile = require $filename; |
111 | 113 | $this->declareGetters($defaultsFromFile); |
112 | 114 | $this->declareStructure($this->configName, $this->defaultValues->get($defaultsFromFile)); |
113 | - } else { |
|
114 | - if (!$this->files->exists($filename)) { |
|
115 | + } |
|
116 | + else |
|
117 | + { |
|
118 | + if (!$this->files->exists($filename)) |
|
119 | + { |
|
115 | 120 | $this->touchConfigFile($filename); |
116 | 121 | } |
117 | 122 | |
@@ -169,7 +174,8 @@ discard block |
||
169 | 174 | $getters = []; |
170 | 175 | $gettersByKey = []; |
171 | 176 | |
172 | - foreach ($defaults as $key => $value) { |
|
177 | + foreach ($defaults as $key => $value) |
|
178 | + { |
|
173 | 179 | $key = (string)$key; |
174 | 180 | $getter = $this->makeGetterName($key); |
175 | 181 | $getters[] = $getter; |
@@ -178,19 +184,23 @@ discard block |
||
178 | 184 | $method->setSource("return \$this->config['$key'];"); |
179 | 185 | $method->setComment("@return {$this->typeAnnotations->getAnnotation($value)}"); |
180 | 186 | |
181 | - if (is_array($value)) { |
|
187 | + if (is_array($value)) |
|
188 | + { |
|
182 | 189 | $gettersByKey[] = compact('key', 'value'); |
183 | 190 | } |
184 | 191 | |
185 | 192 | $returnTypeHint = $this->typeHints->getHint(gettype($value)); |
186 | - if ($returnTypeHint !== null) { |
|
193 | + if ($returnTypeHint !== null) |
|
194 | + { |
|
187 | 195 | $method->setReturn($returnTypeHint); |
188 | 196 | } |
189 | 197 | } |
190 | 198 | |
191 | - foreach ($gettersByKey as $item) { |
|
199 | + foreach ($gettersByKey as $item) |
|
200 | + { |
|
192 | 201 | $method = $this->declareGettersByKey($getters, $item['key'], $item['value']); |
193 | - if ($method !== null) { |
|
202 | + if ($method !== null) |
|
203 | + { |
|
194 | 204 | $getters[] = $method->getName(); |
195 | 205 | } |
196 | 206 | } |
@@ -207,30 +217,35 @@ discard block |
||
207 | 217 | private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method |
208 | 218 | { |
209 | 219 | //Won't create if there's less than 2 sub-items |
210 | - if (count($value) < 2) { |
|
220 | + if (count($value) < 2) |
|
221 | + { |
|
211 | 222 | return null; |
212 | 223 | } |
213 | 224 | |
214 | 225 | $singularKey = $this->singularize($key); |
215 | 226 | $name = $this->makeGetterName($singularKey); |
216 | - if (in_array($name, $methodNames, true)) { |
|
227 | + if (in_array($name, $methodNames, true)) |
|
228 | + { |
|
217 | 229 | $name = $this->makeGetterName($singularKey, 'get', 'by'); |
218 | 230 | } |
219 | 231 | |
220 | 232 | //Name conflict, won't merge |
221 | - if (in_array($name, $methodNames, true)) { |
|
233 | + if (in_array($name, $methodNames, true)) |
|
234 | + { |
|
222 | 235 | return null; |
223 | 236 | } |
224 | 237 | |
225 | 238 | $keyType = defineArrayType(array_keys($value), '-mixed-'); |
226 | 239 | $valueType = defineArrayType(array_values($value), '-mixed-'); |
227 | 240 | //We need a fixed structure here |
228 | - if ($keyType === '-mixed-' || $valueType === '-mixed-') { |
|
241 | + if ($keyType === '-mixed-' || $valueType === '-mixed-') |
|
242 | + { |
|
229 | 243 | return null; |
230 | 244 | } |
231 | 245 | |
232 | 246 | //Won't create for associated arrays |
233 | - if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) { |
|
247 | + if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) |
|
248 | + { |
|
234 | 249 | return null; |
235 | 250 | } |
236 | 251 | |
@@ -244,7 +259,8 @@ discard block |
||
244 | 259 | |
245 | 260 | $param = $method->parameter($singularKey); |
246 | 261 | $paramTypeHint = $this->typeHints->getHint($keyType); |
247 | - if ($paramTypeHint !== null) { |
|
262 | + if ($paramTypeHint !== null) |
|
263 | + { |
|
248 | 264 | $param->setType($paramTypeHint); |
249 | 265 | } |
250 | 266 | |
@@ -260,13 +276,15 @@ discard block |
||
260 | 276 | private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string |
261 | 277 | { |
262 | 278 | $chunks = []; |
263 | - if (!empty($prefix)) { |
|
279 | + if (!empty($prefix)) |
|
280 | + { |
|
264 | 281 | $chunks[] = $prefix; |
265 | 282 | } |
266 | 283 | |
267 | 284 | $name = $this->slugify->slugify($name, ['lowercase' => false]); |
268 | 285 | $chunks[] = count($chunks) !== 0 ? $this->classify($name) : $name; |
269 | - if (!empty($postfix)) { |
|
286 | + if (!empty($postfix)) |
|
287 | + { |
|
270 | 288 | $chunks[] = ucfirst($postfix); |
271 | 289 | } |
272 | 290 |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | string $name, |
64 | 64 | string $comment = '', |
65 | 65 | string $directory = '' |
66 | - ) { |
|
66 | + ){ |
|
67 | 67 | parent::__construct($name, 'InjectableConfig', [], $comment); |
68 | 68 | |
69 | 69 | $this->config = $config; |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | public function create(bool $reverse): void |
88 | 88 | { |
89 | 89 | $filename = $this->makeConfigFilename($this->configName); |
90 | - if ($reverse) { |
|
91 | - if (!$this->files->exists($filename)) { |
|
90 | + if ($reverse){ |
|
91 | + if (!$this->files->exists($filename)){ |
|
92 | 92 | throw new ScaffolderException("Config filename $filename doesn't exist"); |
93 | 93 | } |
94 | 94 | |
95 | 95 | $defaultsFromFile = require $filename; |
96 | 96 | $this->declareGetters($defaultsFromFile); |
97 | 97 | $this->declareStructure($this->configName, $this->defaultValues->get($defaultsFromFile)); |
98 | - } else { |
|
99 | - if (!$this->files->exists($filename)) { |
|
98 | + }else{ |
|
99 | + if (!$this->files->exists($filename)){ |
|
100 | 100 | $this->touchConfigFile($filename); |
101 | 101 | } |
102 | 102 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $getters = []; |
144 | 144 | $gettersByKey = []; |
145 | 145 | |
146 | - foreach ($defaults as $key => $value) { |
|
146 | + foreach ($defaults as $key => $value){ |
|
147 | 147 | $key = (string)$key; |
148 | 148 | $getter = $this->makeGetterName($key); |
149 | 149 | $getters[] = $getter; |
@@ -152,19 +152,19 @@ discard block |
||
152 | 152 | $method->setSource("return \$this->config['$key'];"); |
153 | 153 | $method->setComment("@return {$this->typeAnnotations->getAnnotation($value)}"); |
154 | 154 | |
155 | - if (is_array($value)) { |
|
155 | + if (is_array($value)){ |
|
156 | 156 | $gettersByKey[] = compact('key', 'value'); |
157 | 157 | } |
158 | 158 | |
159 | 159 | $returnTypeHint = $this->typeHints->getHint(gettype($value)); |
160 | - if ($returnTypeHint !== null) { |
|
160 | + if ($returnTypeHint !== null){ |
|
161 | 161 | $method->setReturn($returnTypeHint); |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - foreach ($gettersByKey as $item) { |
|
165 | + foreach ($gettersByKey as $item){ |
|
166 | 166 | $method = $this->declareGettersByKey($getters, $item['key'], $item['value']); |
167 | - if ($method !== null) { |
|
167 | + if ($method !== null){ |
|
168 | 168 | $getters[] = $method->getName(); |
169 | 169 | } |
170 | 170 | } |
@@ -175,30 +175,30 @@ discard block |
||
175 | 175 | private function declareGettersByKey(array $methodNames, string $key, array $value): ?Method |
176 | 176 | { |
177 | 177 | //Won't create if there's less than 2 sub-items |
178 | - if (count($value) < 2) { |
|
178 | + if (count($value) < 2){ |
|
179 | 179 | return null; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $singularKey = $this->singularize($key); |
183 | 183 | $name = $this->makeGetterName($singularKey); |
184 | - if (in_array($name, $methodNames, true)) { |
|
184 | + if (in_array($name, $methodNames, true)){ |
|
185 | 185 | $name = $this->makeGetterName($singularKey, 'get', 'by'); |
186 | 186 | } |
187 | 187 | |
188 | 188 | //Name conflict, won't merge |
189 | - if (in_array($name, $methodNames, true)) { |
|
189 | + if (in_array($name, $methodNames, true)){ |
|
190 | 190 | return null; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $keyType = defineArrayType(array_keys($value), '-mixed-'); |
194 | 194 | $valueType = defineArrayType(array_values($value), '-mixed-'); |
195 | 195 | //We need a fixed structure here |
196 | - if ($keyType === '-mixed-' || $valueType === '-mixed-') { |
|
196 | + if ($keyType === '-mixed-' || $valueType === '-mixed-'){ |
|
197 | 197 | return null; |
198 | 198 | } |
199 | 199 | |
200 | 200 | //Won't create for associated arrays |
201 | - if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)) { |
|
201 | + if ($this->typeAnnotations->mapType($keyType) === 'int' && !isAssociativeArray($value)){ |
|
202 | 202 | return null; |
203 | 203 | } |
204 | 204 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | |
213 | 213 | $param = $method->parameter($singularKey); |
214 | 214 | $paramTypeHint = $this->typeHints->getHint($keyType); |
215 | - if ($paramTypeHint !== null) { |
|
215 | + if ($paramTypeHint !== null){ |
|
216 | 216 | $param->setType($paramTypeHint); |
217 | 217 | } |
218 | 218 | |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | private function makeGetterName(string $name, string $prefix = 'get', string $postfix = ''): string |
223 | 223 | { |
224 | 224 | $chunks = []; |
225 | - if (!empty($prefix)) { |
|
225 | + if (!empty($prefix)){ |
|
226 | 226 | $chunks[] = $prefix; |
227 | 227 | } |
228 | 228 | |
229 | 229 | $name = $this->slugify->slugify($name, ['lowercase' => false]); |
230 | 230 | $chunks[] = count($chunks) !== 0 ? $this->classify($name) : $name; |
231 | - if (!empty($postfix)) { |
|
231 | + if (!empty($postfix)){ |
|
232 | 232 | $chunks[] = ucfirst($postfix); |
233 | 233 | } |
234 | 234 | |
@@ -247,14 +247,14 @@ discard block |
||
247 | 247 | |
248 | 248 | private function classify(string $name): string |
249 | 249 | { |
250 | - return ( new InflectorFactory() ) |
|
250 | + return (new InflectorFactory()) |
|
251 | 251 | ->build() |
252 | 252 | ->classify($name); |
253 | 253 | } |
254 | 254 | |
255 | 255 | private function singularize(string $name): string |
256 | 256 | { |
257 | - return ( new InflectorFactory() ) |
|
257 | + return (new InflectorFactory()) |
|
258 | 258 | ->build() |
259 | 259 | ->singularize($name); |
260 | 260 | } |
@@ -122,7 +122,7 @@ |
||
122 | 122 | $this->files->write( |
123 | 123 | $filename, |
124 | 124 | $file->render(), |
125 | - FilesInterface::READONLY, |
|
125 | + FilesInterface::readonly, |
|
126 | 126 | true |
127 | 127 | ); |
128 | 128 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | $source = $this->method('up')->getSource(); |
52 | 52 | |
53 | 53 | $source->addLine("\$this->table('{$table}')"); |
54 | - foreach ($columns as $name => $type) { |
|
54 | + foreach ($columns as $name => $type){ |
|
55 | 55 | $source->addLine(" ->addColumn('{$name}', '{$type}')"); |
56 | 56 | } |
57 | 57 |
@@ -51,7 +51,8 @@ |
||
51 | 51 | $source = $this->method('up')->getSource(); |
52 | 52 | |
53 | 53 | $source->addLine("\$this->table('{$table}')"); |
54 | - foreach ($columns as $name => $type) { |
|
54 | + foreach ($columns as $name => $type) |
|
55 | + { |
|
55 | 56 | $source->addLine(" ->addColumn('{$name}', '{$type}')"); |
56 | 57 | } |
57 | 58 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function getAnnotation($value): string |
39 | 39 | { |
40 | - if (is_array($value)) { |
|
40 | + if (is_array($value)){ |
|
41 | 41 | return $this->arrayAnnotationString($value); |
42 | 42 | } |
43 | 43 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | private function arrayAnnotationString(array $value): string |
61 | 61 | { |
62 | 62 | $types = []; |
63 | - foreach ($value as $item) { |
|
63 | + foreach ($value as $item){ |
|
64 | 64 | $types[] = gettype($item); |
65 | 65 | } |
66 | 66 | $types = array_unique($types); |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function getAnnotation($value): string |
39 | 39 | { |
40 | - if (is_array($value)) { |
|
40 | + if (is_array($value)) |
|
41 | + { |
|
41 | 42 | return $this->arrayAnnotationString($value); |
42 | 43 | } |
43 | 44 | |
@@ -60,7 +61,8 @@ discard block |
||
60 | 61 | private function arrayAnnotationString(array $value): string |
61 | 62 | { |
62 | 63 | $types = []; |
63 | - foreach ($value as $item) { |
|
64 | + foreach ($value as $item) |
|
65 | + { |
|
64 | 66 | $types[] = gettype($item); |
65 | 67 | } |
66 | 68 | $types = array_unique($types); |