@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! function_exists('get_module_path')) { |
|
3 | +if (!function_exists('get_module_path')) { |
|
4 | 4 | function get_module_path(string $module) |
5 | 5 | { |
6 | 6 | $module = ucfirst($module); |
@@ -12,21 +12,21 @@ discard block |
||
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
15 | -if (! function_exists('get_foundation_path')) { |
|
15 | +if (!function_exists('get_foundation_path')) { |
|
16 | 16 | function get_foundation_path() |
17 | 17 | { |
18 | 18 | return base_path('src/Foundation'); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | -if (! function_exists('get_authenticated_user_id')) { |
|
22 | +if (!function_exists('get_authenticated_user_id')) { |
|
23 | 23 | function get_authenticated_user_id() |
24 | 24 | { |
25 | 25 | return get_authenticated_user()->id; |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | -if (! function_exists('get_authenticated_user')) { |
|
29 | +if (!function_exists('get_authenticated_user')) { |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * @return \Modules\User\Entities\User |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | -if (! function_exists('get_short_class_name')) { |
|
44 | +if (!function_exists('get_short_class_name')) { |
|
45 | 45 | function get_short_class_name($class) |
46 | 46 | { |
47 | - if (! is_string($class)) { |
|
47 | + if (!is_string($class)) { |
|
48 | 48 | $class = get_class($class); |
49 | 49 | } |
50 | 50 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -if (! function_exists('get_random_array_element')) { |
|
55 | +if (!function_exists('get_random_array_element')) { |
|
56 | 56 | function get_random_array_element(array $array) |
57 | 57 | { |
58 | 58 | if (empty($array)) { |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | } |
61 | 61 | $randomIndex = random_int(0, count($array) - 1); |
62 | 62 | |
63 | - return $array[$randomIndex]; |
|
63 | + return $array[ $randomIndex ]; |
|
64 | 64 | } |
65 | 65 | } |
66 | -if (! function_exists('create_multiple_from_factory')) { |
|
66 | +if (!function_exists('create_multiple_from_factory')) { |
|
67 | 67 | function create_multiple_from_factory(string $modelClass, $amount = 1, ?string $state = null) |
68 | 68 | { |
69 | 69 | if ($amount < 1) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | -if (! function_exists('create_from_factory')) { |
|
83 | +if (!function_exists('create_from_factory')) { |
|
84 | 84 | function create_from_factory(string $modelClass, ?string $state = null) |
85 | 85 | { |
86 | 86 | $factory = factory($modelClass); |
@@ -93,33 +93,33 @@ discard block |
||
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | -if (! function_exists('class_implements_interface')) { |
|
96 | +if (!function_exists('class_implements_interface')) { |
|
97 | 97 | function class_implements_interface($class, $interface) |
98 | 98 | { |
99 | 99 | return in_array($interface, class_implements($class)); |
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | -if (! function_exists('class_uses_trait')) { |
|
103 | +if (!function_exists('class_uses_trait')) { |
|
104 | 104 | function class_uses_trait($class, string $trait) |
105 | 105 | { |
106 | - if (! is_string($class)) { |
|
106 | + if (!is_string($class)) { |
|
107 | 107 | $class = get_class($class); |
108 | 108 | } |
109 | 109 | |
110 | 110 | $traits = array_flip(class_uses_recursive($class)); |
111 | 111 | |
112 | - return isset($traits[$trait]); |
|
112 | + return isset($traits[ $trait ]); |
|
113 | 113 | } |
114 | 114 | } |
115 | -if (! function_exists('array_keys_exists')) { |
|
115 | +if (!function_exists('array_keys_exists')) { |
|
116 | 116 | function array_keys_exists(array $keys, array $arr) |
117 | 117 | { |
118 | - return ! array_diff_key(array_flip($keys), $arr); |
|
118 | + return !array_diff_key(array_flip($keys), $arr); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
122 | -if (! function_exists('array_is_subset_of')) { |
|
122 | +if (!function_exists('array_is_subset_of')) { |
|
123 | 123 | function array_is_subset_of(array $subset, array $array, bool $strict = false) |
124 | 124 | { |
125 | 125 | $arrayAssociative = is_associative_array($array); |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | } |
136 | 136 | |
137 | 137 | return $result; |
138 | - } elseif (($subsetAssociative && ! $arrayAssociative) || |
|
139 | - (! $subsetAssociative && $arrayAssociative)) { |
|
138 | + } elseif (($subsetAssociative && !$arrayAssociative) || |
|
139 | + (!$subsetAssociative && $arrayAssociative)) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | -if (! function_exists('is_associative_array')) { |
|
153 | +if (!function_exists('is_associative_array')) { |
|
154 | 154 | function is_associative_array(array $arr) |
155 | 155 | { |
156 | - if ([] === $arr) { |
|
156 | + if ([ ] === $arr) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | -if (! function_exists('get_class_property')) { |
|
164 | +if (!function_exists('get_class_property')) { |
|
165 | 165 | function get_class_property($class, string $property) |
166 | 166 | { |
167 | - if (! is_string($class)) { |
|
167 | + if (!is_string($class)) { |
|
168 | 168 | $class = get_class($class); |
169 | 169 | } |
170 | 170 | |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
183 | -if (! function_exists('instance_without_constructor')) { |
|
183 | +if (!function_exists('instance_without_constructor')) { |
|
184 | 184 | function instance_without_constructor($class) |
185 | 185 | { |
186 | - if (! is_string($class)) { |
|
186 | + if (!is_string($class)) { |
|
187 | 187 | $class = get_class($class); |
188 | 188 | } |
189 | 189 | |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | -if (! function_exists('call_class_function')) { |
|
203 | +if (!function_exists('call_class_function')) { |
|
204 | 204 | function call_class_function($class, string $methodName) |
205 | 205 | { |
206 | 206 | return instance_without_constructor($class)->$methodName(); |
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | -if (! function_exists('get_class_constants')) { |
|
210 | +if (!function_exists('get_class_constants')) { |
|
211 | 211 | function get_class_constants($class) |
212 | 212 | { |
213 | - if (! is_string($class)) { |
|
213 | + if (!is_string($class)) { |
|
214 | 214 | $class = get_class($class); |
215 | 215 | } |
216 | 216 |
@@ -26,6 +26,6 @@ |
||
26 | 26 | |
27 | 27 | public function decode() |
28 | 28 | { |
29 | - return json_decode($this->getContent(), true)['data'] ?? json_decode($this->getContent(), true); |
|
29 | + return json_decode($this->getContent(), true)[ 'data' ] ?? json_decode($this->getContent(), true); |
|
30 | 30 | } |
31 | 31 | } |
@@ -19,15 +19,15 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | if ($unwrap) { |
22 | - return json_decode($content, true)['data'] ?? json_decode($content, true); |
|
22 | + return json_decode($content, true)[ 'data' ] ?? json_decode($content, true); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return json_decode($content, true); |
26 | 26 | } |
27 | 27 | |
28 | - protected function http(string $method, string $route, array $payload = [], array $headers = []) : \Foundation\Abstracts\Tests\TestResponse |
|
28 | + protected function http(string $method, string $route, array $payload = [ ], array $headers = [ ]) : \Foundation\Abstracts\Tests\TestResponse |
|
29 | 29 | { |
30 | - if (! in_array($method, ['GET', 'POST', 'PATCH', 'DELETE', 'PUT'])) { |
|
30 | + if (!in_array($method, [ 'GET', 'POST', 'PATCH', 'DELETE', 'PUT' ])) { |
|
31 | 31 | throw new \Exception('Invalid Http Method'); |
32 | 32 | } |
33 | 33 |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | private function bootstrapCommands(\Foundation\Core\Module $module) |
91 | 91 | { |
92 | 92 | foreach ($module->getCommands()->getClasses() as $commandClass) { |
93 | - $this->bootstrap['commands'][] = [ |
|
93 | + $this->bootstrap[ 'commands' ][ ] = [ |
|
94 | 94 | 'class' => $commandClass, |
95 | 95 | ]; |
96 | 96 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | private function bootstrapRoutes(\Foundation\Core\Module $module) |
100 | 100 | { |
101 | 101 | foreach ($module->getRoutes()->getFiles() as $file) { |
102 | - $this->bootstrap['routes'][] = [ |
|
102 | + $this->bootstrap[ 'routes' ][ ] = [ |
|
103 | 103 | 'prefix' => $this->generateRoutePrefixFromFileName($file->getFileName()), |
104 | 104 | 'controller_namespace' => $module->getControllers()->getNamespace(), |
105 | 105 | 'domain' => Larapi::getApiDomainName(), |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | private function generateRoutePrefixFromFileName(string $fileName) |
113 | 113 | { |
114 | 114 | $prefixArray = explode('.', $fileName); |
115 | - $prefixVersion = $prefixArray[1]; |
|
116 | - $prefixRoute = $prefixArray[0]; |
|
115 | + $prefixVersion = $prefixArray[ 1 ]; |
|
116 | + $prefixRoute = $prefixArray[ 0 ]; |
|
117 | 117 | |
118 | 118 | return $prefixVersion.'/'.$prefixRoute; |
119 | 119 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | private function bootstrapConfigs(\Foundation\Core\Module $module) |
122 | 122 | { |
123 | 123 | foreach ($module->getConfigs()->getFiles() as $file) { |
124 | - $this->bootstrap['configs'][] = [ |
|
124 | + $this->bootstrap[ 'configs' ][ ] = [ |
|
125 | 125 | 'name' => $file->getName(), |
126 | 126 | 'path' => $file->getPath(), |
127 | 127 | ]; |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | |
131 | 131 | private function bootstrapFactories(\Foundation\Core\Module $module) |
132 | 132 | { |
133 | - $this->bootstrap['factories'][] = [ |
|
133 | + $this->bootstrap[ 'factories' ][ ] = [ |
|
134 | 134 | 'path' => $module->getFactories()->getPath(), |
135 | 135 | ]; |
136 | 136 | } |
137 | 137 | |
138 | 138 | private function bootstrapMigrations(\Foundation\Core\Module $module) |
139 | 139 | { |
140 | - $this->bootstrap['migrations'][] = [ |
|
140 | + $this->bootstrap[ 'migrations' ][ ] = [ |
|
141 | 141 | 'path' => $module->getMigrations()->getPath(), |
142 | 142 | ]; |
143 | 143 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | private function bootstrapSeeders(\Foundation\Core\Module $module) |
146 | 146 | { |
147 | 147 | foreach ($module->getSeeders()->getClasses() as $seederClass) { |
148 | - $this->bootstrap['seeders'][] = [ |
|
148 | + $this->bootstrap[ 'seeders' ][ ] = [ |
|
149 | 149 | 'class' => $seederClass, |
150 | 150 | ]; |
151 | 151 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | private function bootstrapModels(\Foundation\Core\Module $module) |
155 | 155 | { |
156 | 156 | foreach ($module->getModels()->getClasses() as $modelClass) { |
157 | - $this->bootstrap['models'][] = [ |
|
157 | + $this->bootstrap[ 'models' ][ ] = [ |
|
158 | 158 | 'class' => $modelClass, |
159 | 159 | 'observers' => $this->extractObserversFromModel($modelClass), |
160 | 160 | 'policies' => $this->extractPoliciesFromModel($modelClass), |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | |
167 | 167 | private function extractObserversFromModel(string $modelClass) |
168 | 168 | { |
169 | - $observers = []; |
|
170 | - foreach (get_class_property($modelClass, 'observers') ?? [] as $observerClass) { |
|
169 | + $observers = [ ]; |
|
170 | + foreach (get_class_property($modelClass, 'observers') ?? [ ] as $observerClass) { |
|
171 | 171 | if (instance_without_constructor($observerClass) instanceof Observer) { |
172 | - $observers[] = $observerClass; |
|
172 | + $observers[ ] = $observerClass; |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | |
179 | 179 | private function extractPoliciesFromModel(string $modelClass) |
180 | 180 | { |
181 | - $policies = []; |
|
182 | - foreach (get_class_property($modelClass, 'policies') ?? [] as $policyClass) { |
|
181 | + $policies = [ ]; |
|
182 | + foreach (get_class_property($modelClass, 'policies') ?? [ ] as $policyClass) { |
|
183 | 183 | if (instance_without_constructor($policyClass) instanceof Policy) { |
184 | - $policies[] = $policyClass; |
|
184 | + $policies[ ] = $policyClass; |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | { |
193 | 193 | foreach ($module->getServiceProviders()->getClasses() as $serviceProviderClass) { |
194 | 194 | if ($this->passedRegistrationCondition($serviceProviderClass)) { |
195 | - $this->bootstrap['providers'][] = [ |
|
195 | + $this->bootstrap[ 'providers' ][ ] = [ |
|
196 | 196 | 'class' => $serviceProviderClass, |
197 | 197 | ]; |
198 | 198 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | private function passedRegistrationCondition($class) |
203 | 203 | { |
204 | - if (! class_implements_interface($class, ConditionalAutoRegistration::class)) { |
|
204 | + if (!class_implements_interface($class, ConditionalAutoRegistration::class)) { |
|
205 | 205 | return true; |
206 | 206 | } |
207 | 207 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | private function bootstrapEvents(\Foundation\Core\Module $module) |
212 | 212 | { |
213 | 213 | foreach ($module->getEvents()->getClasses() as $eventClass) { |
214 | - $listeners = []; |
|
215 | - foreach (get_class_property($eventClass, 'listeners') ?? [] as $listenerClass) { |
|
214 | + $listeners = [ ]; |
|
215 | + foreach (get_class_property($eventClass, 'listeners') ?? [ ] as $listenerClass) { |
|
216 | 216 | if (instance_without_constructor($listenerClass) instanceof Listener) { |
217 | - $listeners[] = $listenerClass; |
|
217 | + $listeners[ ] = $listenerClass; |
|
218 | 218 | } |
219 | 219 | } |
220 | - $this->bootstrap['events'][] = [ |
|
220 | + $this->bootstrap[ 'events' ][ ] = [ |
|
221 | 221 | 'class' => $eventClass, |
222 | 222 | 'listeners' => $listeners, |
223 | 223 | ]; |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function loadBootstrapFromCache() |
231 | 231 | { |
232 | - if (! isset($this->bootstrap)) { |
|
232 | + if (!isset($this->bootstrap)) { |
|
233 | 233 | if ($this->cacheExists()) { |
234 | 234 | $this->bootstrap = $this->readFromCache(); |
235 | 235 | } else { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function getCommands(): array |
254 | 254 | { |
255 | - return $this->loadBootstrapFromCache()['commands'] ?? []; |
|
255 | + return $this->loadBootstrapFromCache()[ 'commands' ] ?? [ ]; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function getRoutes(): array |
262 | 262 | { |
263 | - return $this->loadBootstrapFromCache()['routes'] ?? []; |
|
263 | + return $this->loadBootstrapFromCache()[ 'routes' ] ?? [ ]; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | */ |
269 | 269 | public function getConfigs(): array |
270 | 270 | { |
271 | - return $this->loadBootstrapFromCache()['configs'] ?? []; |
|
271 | + return $this->loadBootstrapFromCache()[ 'configs' ] ?? [ ]; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function getFactories(): array |
278 | 278 | { |
279 | - return $this->loadBootstrapFromCache()['factories'] ?? []; |
|
279 | + return $this->loadBootstrapFromCache()[ 'factories' ] ?? [ ]; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function getMigrations(): array |
286 | 286 | { |
287 | - return $this->loadBootstrapFromCache()['migrations'] ?? []; |
|
287 | + return $this->loadBootstrapFromCache()[ 'migrations' ] ?? [ ]; |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function getSeeders(): array |
294 | 294 | { |
295 | - return $this->loadBootstrapFromCache()['seeders'] ?? []; |
|
295 | + return $this->loadBootstrapFromCache()[ 'seeders' ] ?? [ ]; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | public function getModels(): array |
302 | 302 | { |
303 | - return $this->loadBootstrapFromCache()['models'] ?? []; |
|
303 | + return $this->loadBootstrapFromCache()[ 'models' ] ?? [ ]; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | public function getPolicies(): array |
310 | 310 | { |
311 | - return $this->loadBootstrapFromCache()['policies'] ?? []; |
|
311 | + return $this->loadBootstrapFromCache()[ 'policies' ] ?? [ ]; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | public function getProviders(): array |
318 | 318 | { |
319 | - return $this->loadBootstrapFromCache()['providers'] ?? []; |
|
319 | + return $this->loadBootstrapFromCache()[ 'providers' ] ?? [ ]; |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -324,6 +324,6 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function getEvents(): array |
326 | 326 | { |
327 | - return $this->loadBootstrapFromCache()['events'] ?? []; |
|
327 | + return $this->loadBootstrapFromCache()[ 'events' ] ?? [ ]; |
|
328 | 328 | } |
329 | 329 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $this->bootstrapService = new BootstrapRegistrarService(); |
63 | 63 | |
64 | - if (! ($this->app->environment('production'))) { |
|
64 | + if (!($this->app->environment('production'))) { |
|
65 | 65 | $this->bootstrapService->recache(); |
66 | 66 | } |
67 | 67 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | private function loadCommands() |
70 | 70 | { |
71 | 71 | foreach ($this->bootstrapService->getCommands() as $command) { |
72 | - $this->commands($command['class']); |
|
72 | + $this->commands($command[ 'class' ]); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -78,17 +78,17 @@ discard block |
||
78 | 78 | $moduleModel = null; |
79 | 79 | foreach ($this->bootstrapService->getRoutes() as $route) { |
80 | 80 | Route::group([ |
81 | - 'prefix' => $route['prefix'], |
|
82 | - 'namespace' => $route['controller_namespace'], |
|
83 | - 'domain' => $route['domain'], |
|
84 | - 'middleware' => ['api'], |
|
85 | - ], function () use ($route) { |
|
86 | - require $route['path']; |
|
81 | + 'prefix' => $route[ 'prefix' ], |
|
82 | + 'namespace' => $route[ 'controller_namespace' ], |
|
83 | + 'domain' => $route[ 'domain' ], |
|
84 | + 'middleware' => [ 'api' ], |
|
85 | + ], function() use ($route) { |
|
86 | + require $route[ 'path' ]; |
|
87 | 87 | }); |
88 | - if ($moduleModel !== $route['module_model']) { |
|
89 | - Route::model(strtolower(get_short_class_name($route['module_model'])), $route['module_model']); |
|
88 | + if ($moduleModel !== $route[ 'module_model' ]) { |
|
89 | + Route::model(strtolower(get_short_class_name($route[ 'module_model' ])), $route[ 'module_model' ]); |
|
90 | 90 | } |
91 | - $moduleModel = $route['module_model']; |
|
91 | + $moduleModel = $route[ 'module_model' ]; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | { |
102 | 102 | foreach ($this->bootstrapService->getConfigs() as $config) { |
103 | 103 | $this->mergeConfigFrom( |
104 | - $config['path'], |
|
105 | - $config['name'] |
|
104 | + $config[ 'path' ], |
|
105 | + $config[ 'name' ] |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | } |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | public function loadFactories() |
116 | 116 | { |
117 | 117 | foreach ($this->bootstrapService->getFactories() as $factory) { |
118 | - if (! $this->app->environment('production')) { |
|
119 | - app(Factory::class)->load($factory['path']); |
|
118 | + if (!$this->app->environment('production')) { |
|
119 | + app(Factory::class)->load($factory[ 'path' ]); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | public function loadMigrations() |
130 | 130 | { |
131 | 131 | foreach ($this->bootstrapService->getMigrations() as $migration) { |
132 | - $this->loadMigrationsFrom($migration['path']); |
|
132 | + $this->loadMigrationsFrom($migration[ 'path' ]); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -137,16 +137,16 @@ discard block |
||
137 | 137 | { |
138 | 138 | $app = $this->app; |
139 | 139 | $service = $this->bootstrapService; |
140 | - $this->app->extend('command.seed', function () use ($app, $service) { |
|
141 | - return new SeedCommand($app['db'], $service); |
|
140 | + $this->app->extend('command.seed', function() use ($app, $service) { |
|
141 | + return new SeedCommand($app[ 'db' ], $service); |
|
142 | 142 | }); |
143 | 143 | } |
144 | 144 | |
145 | 145 | private function loadCacheObservers() |
146 | 146 | { |
147 | 147 | foreach ($this->bootstrapService->getModels() as $model) { |
148 | - if ($model['cacheable']) { |
|
149 | - $model['class']::observe(CacheObserver::class); |
|
148 | + if ($model[ 'cacheable' ]) { |
|
149 | + $model[ 'class' ]::observe(CacheObserver::class); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | private function loadModelPolicies() |
155 | 155 | { |
156 | 156 | foreach ($this->bootstrapService->getModels() as $model) { |
157 | - foreach ($model['policies'] as $policy) { |
|
158 | - Gate::policy($model['class'], $policy); |
|
159 | - if ($model['ownable']) { |
|
157 | + foreach ($model[ 'policies' ] as $policy) { |
|
158 | + Gate::policy($model[ 'class' ], $policy); |
|
159 | + if ($model[ 'ownable' ]) { |
|
160 | 160 | Gate::define('access', OwnershipPolicy::class.'@access'); |
161 | 161 | } |
162 | 162 | } |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | private function loadModelObservers() |
167 | 167 | { |
168 | 168 | foreach ($this->bootstrapService->getModels() as $model) { |
169 | - foreach ($model['observers'] as $observer) { |
|
170 | - $model['class']::observe($observer); |
|
169 | + foreach ($model[ 'observers' ] as $observer) { |
|
170 | + $model[ 'class' ]::observe($observer); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -175,15 +175,15 @@ discard block |
||
175 | 175 | private function loadServiceProviders() |
176 | 176 | { |
177 | 177 | foreach ($this->bootstrapService->getProviders() as $provider) { |
178 | - $this->app->register($provider['class']); |
|
178 | + $this->app->register($provider[ 'class' ]); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | private function loadListeners() |
183 | 183 | { |
184 | 184 | foreach ($this->bootstrapService->getEvents() as $event) { |
185 | - foreach ($event['listeners'] as $listener) { |
|
186 | - Event::listen($event['class'], $listener); |
|
185 | + foreach ($event[ 'listeners' ] as $listener) { |
|
186 | + Event::listen($event[ 'class' ], $listener); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @var File[] |
35 | 35 | */ |
36 | - protected $files = []; |
|
36 | + protected $files = [ ]; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * LarapiModule constructor. |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $files = $this->getAllPhpFileNamesWithoutExtension(); |
59 | 59 | foreach ($files as $file) { |
60 | - $this->files[] = new File($file, $this->getPath().'/'.$file.'.php', $this); |
|
60 | + $this->files[ ] = new File($file, $this->getPath().'/'.$file.'.php', $this); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function getClasses(): array |
108 | 108 | { |
109 | - $classes = []; |
|
109 | + $classes = [ ]; |
|
110 | 110 | foreach ($this->getAllPhpFileNames() as $file) { |
111 | 111 | $shortClassName = str_replace('.php', '', $file); |
112 | 112 | $class = $this->getNamespace().'\\'.$shortClassName; |
113 | 113 | |
114 | 114 | if ($this->baseClass === null || instance_without_constructor($class) instanceof $this->baseClass) { |
115 | - $classes[] = $class; |
|
115 | + $classes[ ] = $class; |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | public function getAllFileNames() |
131 | 131 | { |
132 | 132 | try { |
133 | - $fileNames = array_diff(scandir($this->getPath()), ['..', '.']); |
|
133 | + $fileNames = array_diff(scandir($this->getPath()), [ '..', '.' ]); |
|
134 | 134 | } catch (\ErrorException $e) { |
135 | - $fileNames = []; |
|
135 | + $fileNames = [ ]; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return $fileNames; |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | |
141 | 141 | public function getAllPhpFileNames() |
142 | 142 | { |
143 | - $files = []; |
|
143 | + $files = [ ]; |
|
144 | 144 | foreach ($this->getAllFileNames() as $file) { |
145 | 145 | if ($this->hasPhpExtension($file)) { |
146 | - $files[] = $file; |
|
146 | + $files[ ] = $file; |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | |
153 | 153 | public function getAllPhpFileNamesWithoutExtension() |
154 | 154 | { |
155 | - $files = []; |
|
155 | + $files = [ ]; |
|
156 | 156 | foreach ($this->getAllFileNames() as $file) { |
157 | 157 | if ($this->hasPhpExtension($file)) { |
158 | - $files[] = str_replace('.php', '', $file); |
|
158 | + $files[ ] = str_replace('.php', '', $file); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | private function hasPhpExtension(string $fileName): bool |
171 | 171 | { |
172 | - return strlen($fileName) > 4 && '.php' === ($fileName[-4].$fileName[-3].$fileName[-2].$fileName[-1]); |
|
172 | + return strlen($fileName) > 4 && '.php' === ($fileName[-4 ].$fileName[-3 ].$fileName[-2 ].$fileName[-1 ]); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public static function getModules(): array |
19 | 19 | { |
20 | - $modules = []; |
|
20 | + $modules = [ ]; |
|
21 | 21 | |
22 | 22 | foreach (self::getModuleNames() as $moduleName) { |
23 | - $modules[] = self::getModule($moduleName); |
|
23 | + $modules[ ] = self::getModule($moduleName); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | return $modules; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public static function getModuleNames(): array |
53 | 53 | { |
54 | - return array_diff(scandir(self::getModulesBasePath()), ['..', '.']); |
|
54 | + return array_diff(scandir(self::getModulesBasePath()), [ '..', '.' ]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -12,7 +12,7 @@ |
||
12 | 12 | { |
13 | 13 | public static function allRolePermissions(): array |
14 | 14 | { |
15 | - return once(function () { |
|
15 | + return once(function() { |
|
16 | 16 | }); |
17 | 17 | } |
18 | 18 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | |
19 | 19 | public function getRole(): string |
20 | 20 | { |
21 | - if (! isset($role)) { |
|
21 | + if (!isset($role)) { |
|
22 | 22 | throw new Exception('Role not set for permission '.get_short_class_name(static::class)); |
23 | 23 | } |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | public static function get(): array |
29 | 29 | { |
30 | - return once(function () { |
|
30 | + return once(function() { |
|
31 | 31 | return new static; |
32 | 32 | })->getPermissions(); |
33 | 33 | } |