Completed
Pull Request — master (#2042)
by Solomon
05:44
created
src/Commands/Actions/CheckLangCommand.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         $directories = $this->getDirectories($module);
38 38
 
39
-        if (! $directories) {
39
+        if (!$directories) {
40 40
             return;
41 41
         }
42 42
 
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
         $directories = [];
69 69
         if (is_dir($path)) {
70 70
             $directories = $this->laravel['files']->directories($path);
71
-            $directories = array_map(function ($directory) use ($moduleName) {
71
+            $directories = array_map(function($directory) use ($moduleName) {
72 72
                 return [
73 73
                     'name' => basename($directory),
74 74
                     'module' => $moduleName,
75 75
                     'path' => $directory,
76
-                    'files' => array_map(function ($file) {
76
+                    'files' => array_map(function($file) {
77 77
                         return basename($file);
78 78
                     }, \File::glob($directory.DIRECTORY_SEPARATOR.'*')),
79 79
                 ];
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 
103 103
         $uniqeLangFiles = $directories->pluck('files')->flatten()->unique()->values();
104 104
 
105
-        $directories->each(function ($directory) use ($uniqeLangFiles, &$missingFilesMessage) {
105
+        $directories->each(function($directory) use ($uniqeLangFiles, &$missingFilesMessage) {
106 106
 
107 107
             $missingFiles = $uniqeLangFiles->diff($directory['files']);
108 108
 
109 109
             if ($missingFiles->count() > 0) {
110
-                $missingFiles->each(function ($missingFile) use ($directory, &$missingFilesMessage) {
110
+                $missingFiles->each(function($missingFile) use ($directory, &$missingFilesMessage) {
111 111
                     $missingFilesMessage[$directory['name']][] = " {$directory['module']} - Missing language file: {$directory['name']}/{$missingFile}";
112 112
                 });
113 113
             }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
         if (count($missingFilesMessage) > 0) {
117 117
 
118
-            collect($missingFilesMessage)->each(function ($messages, $langDirectory) {
118
+            collect($missingFilesMessage)->each(function($messages, $langDirectory) {
119 119
 
120 120
                 $this->components->error("Missing language files in $langDirectory directory");
121 121
 
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
         $langDirectories = $directories->pluck('name');
136 136
 
137 137
         $missingKeysMessage = [];
138
-        $directories->each(function ($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) {
138
+        $directories->each(function($directory) use ($uniqeLangFiles, $langDirectories, &$missingKeysMessage) {
139 139
 
140
-            $uniqeLangFiles->each(function ($file) use ($directory, $langDirectories, &$missingKeysMessage) {
140
+            $uniqeLangFiles->each(function($file) use ($directory, $langDirectories, &$missingKeysMessage) {
141 141
                 $langKeys = $this->getLangKeys($directory['path'].DIRECTORY_SEPARATOR.$file);
142 142
 
143 143
                 if ($langKeys == false) {
144 144
                     return;
145 145
                 }
146 146
 
147
-                $langDirectories->each(function ($langDirectory) use ($directory, $file, $langKeys, &$missingKeysMessage) {
147
+                $langDirectories->each(function($langDirectory) use ($directory, $file, $langKeys, &$missingKeysMessage) {
148 148
 
149 149
                     if ($directory['name'] != $langDirectory) {
150 150
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                         $missingKeys = $langKeys->diff($otherLangKeys);
160 160
                         if ($missingKeys->count() > 0) {
161 161
 
162
-                            $missingKeys->each(function ($missingKey) use ($directory, $langDirectory, $file, &$missingKeysMessage) {
162
+                            $missingKeys->each(function($missingKey) use ($directory, $langDirectory, $file, &$missingKeysMessage) {
163 163
                                 $missingKeysMessage[$langDirectory][] = " {$directory['module']} - Missing language key: {$langDirectory}/{$file} | key: $missingKey";
164 164
                             });
165 165
                         }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
         if (count($missingKeysMessage) > 0) {
172 172
 
173
-            collect($missingKeysMessage)->each(function ($messages, $langDirectory) {
173
+            collect($missingKeysMessage)->each(function($messages, $langDirectory) {
174 174
 
175 175
                 $this->components->error("Missing language keys for directory $langDirectory:");
176 176
 
Please login to merge, or discard this patch.
src/Commands/Actions/DumpCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
     {
25 25
         $module = $this->getModuleModel($name);
26 26
 
27
-        $this->components->task("Generating for <fg=cyan;options=bold>{$module->getName()}</> Module", function () use ($module) {
27
+        $this->components->task("Generating for <fg=cyan;options=bold>{$module->getName()}</> Module", function() use ($module) {
28 28
             chdir($module->path());
29 29
 
30 30
             passthru('composer dump -o -n -q');
Please login to merge, or discard this patch.
src/Commands/ComposerUpdateCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $module = $this->getModuleModel($name);
26 26
 
27
-        $this->components->task("Updating Composer.json <fg=cyan;options=bold>{$module->getName()}</> Module", function () use ($module) {
27
+        $this->components->task("Updating Composer.json <fg=cyan;options=bold>{$module->getName()}</> Module", function() use ($module) {
28 28
 
29 29
             $composer_path = $module->path('composer.json');
30 30
 
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 
33 33
             $autoload = data_get($composer, 'autoload.psr-4');
34 34
 
35
-            if (! $autoload) {
35
+            if (!$autoload) {
36 36
                 return;
37 37
             }
38 38
 
39 39
             $key_name_with_app = sprintf('Modules\\%s\\App\\', $module->getStudlyName());
40 40
 
41
-            if (! array_key_exists($key_name_with_app, $autoload)) {
41
+            if (!array_key_exists($key_name_with_app, $autoload)) {
42 42
                 return;
43 43
             }
44 44
 
Please login to merge, or discard this patch.
src/Traits/PathNamespace.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
             $replace = $ds === '/' ? '\\' : '/';
16 16
         }
17 17
 
18
-        return Str::of($path)->rtrim($ds)->replace($replace, $ds)->explode($ds)->filter(fn ($segment, $key) => $key == 0 or ! empty($segment))->implode($ds);
18
+        return Str::of($path)->rtrim($ds)->replace($replace, $ds)->explode($ds)->filter(fn ($segment, $key) => $key == 0 or !empty($segment))->implode($ds);
19 19
     }
20 20
 
21 21
     /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     public function module_namespace(string $module, ?string $path = null): string
89 89
     {
90 90
         $module_namespace = rtrim(config('modules.namespace') ?? config('modules.paths.modules'), '\\').'\\'.($module);
91
-        if (! empty($path)) {
91
+        if (!empty($path)) {
92 92
             $module_namespace .= '\\'.trim($path, '\\');
93 93
         }
94 94
 
Please login to merge, or discard this patch.
src/Migrations/Migrator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getMigrations($reverse = false)
115 115
     {
116
-        if (! empty($this->subpath)) {
116
+        if (!empty($this->subpath)) {
117 117
             $files = $this->laravel['files']->glob($this->path($this->subpath));
118 118
         } else {
119 119
             $files = $this->laravel['files']->glob($this->path().'/*_*.php');
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             return [];
127 127
         }
128 128
 
129
-        $files = array_map(function ($file) {
129
+        $files = array_map(function($file) {
130 130
             return str_replace('.php', '', basename($file));
131 131
         }, $files);
132 132
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 
231 231
         $class = Str::studly($name);
232 232
 
233
-        if (! class_exists($class) && file_exists($this->path($file.'.php'))) {
233
+        if (!class_exists($class) && file_exists($this->path($file.'.php'))) {
234 234
             return include $this->path($file.'.php');
235 235
         }
236 236
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
         $result = $query->orderBy('migration', 'desc')->get();
326 326
 
327
-        return collect($result)->map(function ($item) {
327
+        return collect($result)->map(function($item) {
328 328
             return (array) $item;
329 329
         })->pluck('migration');
330 330
     }
Please login to merge, or discard this patch.
src/Collection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
      */
21 21
     public function toArray(): array
22 22
     {
23
-        return array_map(function ($value) {
23
+        return array_map(function($value) {
24 24
             if ($value instanceof Module) {
25 25
                 $attributes = $value->json()->getAttributes();
26 26
                 $attributes['path'] = $value->path();
Please login to merge, or discard this patch.
src/LaravelModulesServiceProvider.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         ]);
41 41
 
42 42
         // Create @module() blade directive.
43
-        Blade::if('module', function (string $name) {
43
+        Blade::if ('module', function(string $name) {
44 44
             return module($name);
45 45
         });
46 46
     }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $path = $this->app['config']->get('modules.stubs.path') ?? __DIR__.'/Commands/stubs';
69 69
         Stub::setBasePath($path);
70 70
 
71
-        $this->app->booted(function ($app) {
71
+        $this->app->booted(function($app) {
72 72
             /** @var RepositoryInterface $moduleRepository */
73 73
             $moduleRepository = $app[RepositoryInterface::class];
74 74
             if ($moduleRepository->config('stubs.enabled') === true) {
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
      */
83 83
     protected function registerServices()
84 84
     {
85
-        $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
85
+        $this->app->singleton(Contracts\RepositoryInterface::class, function($app) {
86 86
             $path = $app['config']->get('modules.paths.modules');
87 87
 
88 88
             return new Laravel\LaravelFileRepository($app, $path);
89 89
         });
90
-        $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) {
90
+        $this->app->singleton(Contracts\ActivatorInterface::class, function($app) {
91 91
             $activator = $app['config']->get('modules.activator');
92 92
             $class = $app['config']->get('modules.activators.'.$activator)['class'];
93 93
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 
103 103
     protected function registerMigrations(): void
104 104
     {
105
-        if (! $this->app['config']->get('modules.auto-discover.migrations', true)) {
105
+        if (!$this->app['config']->get('modules.auto-discover.migrations', true)) {
106 106
             return;
107 107
         }
108 108
 
109
-        $this->app->resolving(Migrator::class, function (Migrator $migrator) {
109
+        $this->app->resolving(Migrator::class, function(Migrator $migrator) {
110 110
             $migration_path = $this->app['config']->get('modules.paths.generator.migration.path');
111 111
             collect(\Nwidart\Modules\Facades\Module::allEnabled())
112
-                ->each(function (\Nwidart\Modules\Laravel\Module $module) use ($migration_path, $migrator) {
112
+                ->each(function(\Nwidart\Modules\Laravel\Module $module) use ($migration_path, $migrator) {
113 113
                     $migrator->path($module->path($migration_path));
114 114
                 });
115 115
         });
@@ -117,16 +117,16 @@  discard block
 block discarded – undo
117 117
 
118 118
     protected function registerTranslations(): void
119 119
     {
120
-        if (! $this->app['config']->get('modules.auto-discover.translations', true)) {
120
+        if (!$this->app['config']->get('modules.auto-discover.translations', true)) {
121 121
             return;
122 122
         }
123
-        $this->callAfterResolving('translator', function (TranslatorContract $translator) {
124
-            if (! $translator instanceof Translator) {
123
+        $this->callAfterResolving('translator', function(TranslatorContract $translator) {
124
+            if (!$translator instanceof Translator) {
125 125
                 return;
126 126
             }
127 127
 
128 128
             collect(\Nwidart\Modules\Facades\Module::allEnabled())
129
-                ->each(function (\Nwidart\Modules\Laravel\Module $module) use ($translator) {
129
+                ->each(function(\Nwidart\Modules\Laravel\Module $module) use ($translator) {
130 130
                     $path = $module->path($this->app['config']->get('modules.paths.generator.lang.path'));
131 131
                     $translator->addNamespace($module->getLowerName(), $path);
132 132
                     $translator->addJsonPath($path);
Please login to merge, or discard this patch.
src/Module.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $file = 'module.json';
237 237
         }
238 238
 
239
-        return Arr::get($this->moduleJson, $file, function () use ($file) {
239
+        return Arr::get($this->moduleJson, $file, function() use ($file) {
240 240
             return $this->moduleJson[$file] = new Json($this->path($file), $this->files);
241 241
         });
242 242
     }
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function isDisabled(): bool
337 337
     {
338
-        return ! $this->isEnabled();
338
+        return !$this->isEnabled();
339 339
     }
340 340
 
341 341
     /**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     {
404 404
         return config('modules.register.files', 'register') === 'boot' &&
405 405
             // force register method if option == boot && app is AsgardCms
406
-            ! class_exists('\Modules\Core\Foundation\AsgardCms');
406
+            !class_exists('\Modules\Core\Foundation\AsgardCms');
407 407
     }
408 408
 
409 409
     /**
Please login to merge, or discard this patch.
src/Generators/ModuleGenerator.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     /**
265 265
      * Set force status.
266 266
      */
267
-    public function setForce(bool|int $force): self
267
+    public function setForce(bool | int $force): self
268 268
     {
269 269
         $this->force = $force;
270 270
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
         foreach ($this->getFiles() as $stub => $file) {
356 356
             $path = $this->module->getModulePath($this->getName()).$file;
357 357
 
358
-            $this->component->task("Generating file {$path}", function () use ($stub, $path) {
359
-                if (! $this->filesystem->isDirectory($dir = dirname($path))) {
358
+            $this->component->task("Generating file {$path}", function() use ($stub, $path) {
359
+                if (!$this->filesystem->isDirectory($dir = dirname($path))) {
360 360
                     $this->filesystem->makeDirectory($dir, 0775, true);
361 361
                 }
362 362
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
         $eventGeneratorConfig = GenerateConfigReader::read('event-provider');
399 399
         if (
400 400
             (is_null($eventGeneratorConfig->path()) && $providerGenerator->generate())
401
-            || (! is_null($eventGeneratorConfig->path()) && $eventGeneratorConfig->generate())
401
+            || (!is_null($eventGeneratorConfig->path()) && $eventGeneratorConfig->generate())
402 402
         ) {
403 403
             $this->console->call('module:make-event-provider', [
404 404
                 'module' => $this->getName(),
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
         $routeGeneratorConfig = GenerateConfigReader::read('route-provider');
418 418
         if (
419 419
             (is_null($routeGeneratorConfig->path()) && $providerGenerator->generate())
420
-            || (! is_null($routeGeneratorConfig->path()) && $routeGeneratorConfig->generate())
420
+            || (!is_null($routeGeneratorConfig->path()) && $routeGeneratorConfig->generate())
421 421
         ) {
422 422
             $this->console->call('module:route-provider', [
423 423
                 'module' => $this->getName(),
@@ -470,23 +470,23 @@  discard block
 block discarded – undo
470 470
         $replacements = $this->module->config('stubs.replacements');
471 471
 
472 472
         // Temporarily check if the replacements are defined; remove in the next major version.
473
-        if (! isset($replacements['composer']['APP_PATH'])) {
473
+        if (!isset($replacements['composer']['APP_PATH'])) {
474 474
             $replacements['composer'][] = 'APP_PATH';
475 475
         }
476 476
 
477
-        if (! isset($replacements['composer']['APP_PATH_NAMESPACE'])) {
477
+        if (!isset($replacements['composer']['APP_PATH_NAMESPACE'])) {
478 478
             $replacements['composer'][] = 'APP_PATH_NAMESPACE';
479 479
         }
480 480
 
481
-        if (! isset($replacements['routes/web']['PLURAL_LOWER_NAME'])) {
481
+        if (!isset($replacements['routes/web']['PLURAL_LOWER_NAME'])) {
482 482
             $replacements['routes/web'][] = 'PLURAL_LOWER_NAME';
483 483
         }
484 484
 
485
-        if (! isset($replacements['routes/api']['PLURAL_LOWER_NAME'])) {
485
+        if (!isset($replacements['routes/api']['PLURAL_LOWER_NAME'])) {
486 486
             $replacements['routes/api'][] = 'PLURAL_LOWER_NAME';
487 487
         }
488 488
 
489
-        if (! isset($replacements[$stub])) {
489
+        if (!isset($replacements[$stub])) {
490 490
             return [];
491 491
         }
492 492
 
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
     {
527 527
         $path = $this->module->getModulePath($this->getName()).'module.json';
528 528
 
529
-        $this->component->task("Generating file $path", function () use ($path) {
530
-            if (! $this->filesystem->isDirectory($dir = dirname($path))) {
529
+        $this->component->task("Generating file $path", function() use ($path) {
530
+            if (!$this->filesystem->isDirectory($dir = dirname($path))) {
531 531
                 $this->filesystem->makeDirectory($dir, 0775, true);
532 532
             }
533 533
 
Please login to merge, or discard this patch.