@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public function findInDirectory(string $directory): array |
20 | 20 | { |
21 | - $models = []; |
|
21 | + $models = [ ]; |
|
22 | 22 | $iterator = Finder::create()->files()->name('*.php')->in($directory)->depth(0)->sortByName(); |
23 | 23 | |
24 | 24 | foreach ($iterator as $file) { |
25 | 25 | $class = $this->determineClassFromFile($file); |
26 | 26 | if ($class !== null && class_exists($class) && $this->isModelClass($class)) { |
27 | - $models[] = $class; |
|
27 | + $models[ ] = $class; |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | return null; |
45 | 45 | } |
46 | 46 | |
47 | - return $matches[1] . '\\' . rtrim($file->getFilename(), '.php'); |
|
47 | + return $matches[ 1 ] . '\\' . rtrim($file->getFilename(), '.php'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getIncludes(): array |
68 | 68 | { |
69 | - $includes = []; |
|
69 | + $includes = [ ]; |
|
70 | 70 | collect((new ReflectionClass($this->getModel()))->getMethods(ReflectionMethod::IS_PUBLIC)) |
71 | - ->filter(function (ReflectionMethod $method) { |
|
71 | + ->filter(function(ReflectionMethod $method) { |
|
72 | 72 | // We're not interested in inherited methods |
73 | 73 | return $method->getDeclaringClass()->getName() === $this->getModelClass(); |
74 | - })->each(function (ReflectionMethod $method) use (&$includes) { |
|
74 | + })->each(function(ReflectionMethod $method) use (&$includes) { |
|
75 | 75 | // Only include if we can resolve a resource type |
76 | 76 | if (($type = $this->getResourceType($method)) !== null) { |
77 | - $includes[$method->getName()] = "relation|{$type}"; |
|
77 | + $includes[ $method->getName() ] = "relation|{$type}"; |
|
78 | 78 | } |
79 | 79 | }); |
80 | 80 | |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function getDeclaredProperties(): array |
90 | 90 | { |
91 | - $props = []; |
|
91 | + $props = [ ]; |
|
92 | 92 | $table = $this->getModel()->getTable(); |
93 | 93 | foreach (Schema::getColumnListing($table) as $column) { |
94 | 94 | $type = Schema::getColumnType($table, $column); |
95 | - $props[$column] = $this->schemaTypesMap[$type] ?? null; |
|
95 | + $props[ $column ] = $this->schemaTypesMap[ $type ] ?? null; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $props; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function getDefaultProperties(): array |
107 | 107 | { |
108 | - return []; |
|
108 | + return [ ]; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $relation = class_basename($returnType); |
174 | 174 | |
175 | - return $this->relationsMap[$relation] ?? null; |
|
175 | + return $this->relationsMap[ $relation ] ?? null; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -188,12 +188,12 @@ discard block |
||
188 | 188 | list($statement, $returnTypes) = $match; |
189 | 189 | |
190 | 190 | // Build a regex suitable for matching our relationship keys. EG. hasOne|hasMany... |
191 | - $keyPattern = implode('|', array_map(function ($key) { |
|
191 | + $keyPattern = implode('|', array_map(function($key) { |
|
192 | 192 | return preg_quote($key, '/'); |
193 | 193 | }, array_keys($this->relationsMap))); |
194 | 194 | foreach (explode('|', $returnTypes) as $returnType) { |
195 | 195 | if (preg_match("/($keyPattern)\$/i", $returnType, $match)) { |
196 | - return $this->relationsMap[$match[1]] ?? null; |
|
196 | + return $this->relationsMap[ $match[ 1 ] ] ?? null; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | $numLines = $method->getEndLine() - $startLine; |
217 | 217 | $body = implode('', \array_slice(file($method->getFileName()), $startLine, $numLines)); |
218 | 218 | if (preg_match('/^\s*return\s+(.+?);/ms', $body, $match)) { |
219 | - $returnStmt = $match[1]; |
|
219 | + $returnStmt = $match[ 1 ]; |
|
220 | 220 | foreach (array_keys($this->relationsMap) as $returnType) { |
221 | 221 | // Find "->hasMany(" etc. |
222 | - if (preg_match('/->'.preg_quote($returnType, '/').'\(/i', $returnStmt)) { |
|
223 | - return $this->relationsMap[$returnType]; |
|
222 | + if (preg_match('/->' . preg_quote($returnType, '/') . '\(/i', $returnStmt)) { |
|
223 | + return $this->relationsMap[ $returnType ]; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |