Passed
Push — develop ( 6980d6...a67f7f )
by Andrew
14:08
created
src/helpers/Manifest.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
             $bundle->sourcePath,
99 99
             true
100 100
         );
101
-        self::$config['server']['manifestPath'] = Craft::getAlias($bundle->sourcePath);
102
-        self::$config['server']['publicPath'] = $baseAssetsUrl;
101
+        self::$config[ 'server' ][ 'manifestPath' ] = Craft::getAlias($bundle->sourcePath);
102
+        self::$config[ 'server' ][ 'publicPath' ] = $baseAssetsUrl;
103 103
         $useDevServer = getenv('NYS_PLUGIN_DEVSERVER');
104 104
         if ($useDevServer !== false) {
105
-            self::$config['useDevServer'] = (bool)$useDevServer;
105
+            self::$config[ 'useDevServer' ] = (bool) $useDevServer;
106 106
         }
107 107
     }
108 108
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     public static function registerJsModules(array $modules)
117 117
     {
118 118
         $view = Craft::$app->getView();
119
-        foreach($modules as $module) {
119
+        foreach ($modules as $module) {
120 120
             $jsModule = self::getModule(self::$config, $module, 'modern');
121 121
             if ($jsModule) {
122 122
                 $view->registerJsFile($jsModule, [
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     public static function registerCssModules(array $modules)
137 137
     {
138 138
         $view = Craft::$app->getView();
139
-        foreach($modules as $module) {
139
+        foreach ($modules as $module) {
140 140
             $cssModule = self::getModule(self::$config, $module, 'legacy');
141 141
             if ($cssModule) {
142 142
                 $view->registerCssFile($cssModule, [
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
                 return '';
168 168
             }
169 169
         }
170
-        $lines = [];
170
+        $lines = [ ];
171 171
         if ($async) {
172
-            $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>";
173
-            $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>";
172
+            $lines[ ] = "<script type=\"module\" src=\"{$modernModule}\"></script>";
173
+            $lines[ ] = "<script nomodule src=\"{$legacyModule}\"></script>";
174 174
         } else {
175
-            $lines[] = "<script src=\"{$legacyModule}\"></script>";
175
+            $lines[ ] = "<script src=\"{$legacyModule}\"></script>";
176 176
         }
177 177
 
178 178
         return implode("\r\n", $lines);
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
         if ($legacyModule === null) {
194 194
             return '';
195 195
         }
196
-        $lines = [];
196
+        $lines = [ ];
197 197
         if ($async) {
198
-            $lines[] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />";
199
-            $lines[] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>";
198
+            $lines[ ] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />";
199
+            $lines[ ] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>";
200 200
         } else {
201
-            $lines[] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />";
201
+            $lines[ ] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />";
202 202
         }
203 203
 
204 204
         return implode("\r\n", $lines);
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
         $module = self::getModuleEntry($config, $moduleName, $type, $soft);
225 225
         if ($module !== null) {
226 226
             $prefix = self::$isHot
227
-                ? $config['devServer']['publicPath']
228
-                : $config['server']['publicPath'];
227
+                ? $config[ 'devServer' ][ 'publicPath' ]
228
+                : $config[ 'server' ][ 'publicPath' ];
229 229
             // If the module isn't a full URL, prefix it
230 230
             if (!UrlHelper::isAbsoluteUrl($module)) {
231 231
                 $module = self::combinePaths($prefix, $module);
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
         $manifest = self::getManifestFile($config, $type);
267 267
         if ($manifest !== null) {
268 268
             // Make sure it exists in the manifest
269
-            if (empty($manifest[$moduleName])) {
269
+            if (empty($manifest[ $moduleName ])) {
270 270
                 // Don't report errors for any files in SUPPRESS_ERRORS_FOR_MODULES
271 271
                 if (!in_array($moduleName, self::SUPPRESS_ERRORS_FOR_MODULES)) {
272 272
                     self::reportError(Craft::t(
273 273
                         'retour',
274 274
                         'Module does not exist in the manifest: {moduleName}',
275
-                        ['moduleName' => $moduleName]
275
+                        [ 'moduleName' => $moduleName ]
276 276
                     ), $soft);
277 277
                 }
278 278
 
279 279
                 return null;
280 280
             }
281
-            $module = $manifest[$moduleName];
281
+            $module = $manifest[ $moduleName ];
282 282
         }
283 283
 
284 284
         return $module;
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
         $manifest = null;
299 299
         // Determine whether we should use the devServer for HMR or not
300 300
         $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
301
-        self::$isHot = ($devMode && $config['useDevServer']);
301
+        self::$isHot = ($devMode && $config[ 'useDevServer' ]);
302 302
         // Try to get the manifest
303 303
         while ($manifest === null) {
304 304
             $manifestPath = self::$isHot
305
-                ? $config['devServer']['manifestPath']
306
-                : $config['server']['manifestPath'];
305
+                ? $config[ 'devServer' ][ 'manifestPath' ]
306
+                : $config[ 'server' ][ 'manifestPath' ];
307 307
             // Normalize the path
308
-            $path = self::combinePaths($manifestPath, $config['manifest'][$type]);
308
+            $path = self::combinePaths($manifestPath, $config[ 'manifest' ][ $type ]);
309 309
             $manifest = self::getJsonFile($path);
310 310
             // If the manifest isn't found, and it was hot, fall back on non-hot
311 311
             if ($manifest === null) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                 self::reportError(Craft::t(
314 314
                     'retour',
315 315
                     'Manifest file not found at: {manifestPath}',
316
-                    ['manifestPath' => $manifestPath]
316
+                    [ 'manifestPath' => $manifestPath ]
317 317
                 ), true);
318 318
                 if (self::$isHot) {
319 319
                     // Try again, but not with home module replacement
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      */
338 338
     protected static function getJsonFile(string $path)
339 339
     {
340
-        return self::getFileFromUri($path, [JsonHelper::class, 'decodeIfJson']);
340
+        return self::getFileFromUri($path, [ JsonHelper::class, 'decodeIfJson' ]);
341 341
     }
342 342
 
343 343
     /**
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
         // Resolve any aliases
364 364
         $alias = Craft::getAlias($path, false);
365 365
         if ($alias) {
366
-            $path = (string)$alias;
366
+            $path = (string) $alias;
367 367
         }
368 368
         // Make sure it's a full URL
369 369
         if (!UrlHelper::isAbsoluteUrl($path) && !is_file($path)) {
@@ -388,14 +388,14 @@  discard block
 block discarded – undo
388 388
     protected static function getFileContents(string $path, callable $callback = null)
389 389
     {
390 390
         // Return the memoized manifest if it exists
391
-        if (!empty(self::$files[$path])) {
392
-            return self::$files[$path];
391
+        if (!empty(self::$files[ $path ])) {
392
+            return self::$files[ $path ];
393 393
         }
394 394
         // Create the dependency tags
395 395
         $dependency = new TagDependency([
396 396
             'tags' => [
397 397
                 self::CACHE_TAG,
398
-                self::CACHE_TAG.$path,
398
+                self::CACHE_TAG . $path,
399 399
             ],
400 400
         ]);
401 401
         // Set the cache duration based on devMode
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
         // Get the result from the cache, or parse the file
406 406
         $cache = Craft::$app->getCache();
407 407
         $file = $cache->getOrSet(
408
-            self::CACHE_KEY.$path,
409
-            function () use ($path, $callback) {
408
+            self::CACHE_KEY . $path,
409
+            function() use ($path, $callback) {
410 410
                 $result = null;
411 411
                 $contents = @file_get_contents($path);
412 412
                 if ($contents) {
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
             $cacheDuration,
422 422
             $dependency
423 423
         );
424
-        self::$files[$path] = $file;
424
+        self::$files[ $path ] = $file;
425 425
 
426 426
         return $file;
427 427
     }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
     protected static function combinePaths(string ...$paths): string
437 437
     {
438 438
         $last_key = count($paths) - 1;
439
-        array_walk($paths, function (&$val, $key) use ($last_key) {
439
+        array_walk($paths, function(&$val, $key) use ($last_key) {
440 440
             switch ($key) {
441 441
                 case 0:
442 442
                     $val = rtrim($val, '/ ');
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
         $last = array_pop($paths);
455 455
         $paths = array_filter($paths);
456 456
         array_unshift($paths, $first);
457
-        $paths[] = $last;
457
+        $paths[ ] = $last;
458 458
 
459 459
         return implode('/', $paths);
460 460
     }
Please login to merge, or discard this patch.