Passed
Push — develop ( d433db...110c59 )
by Andrew
04:14
created
src/helpers/Manifest.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
         if ($legacyModule === null) {
60 60
             return '';
61 61
         }
62
-        $lines = [];
62
+        $lines = [ ];
63 63
         if ($async) {
64
-            $lines[] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />";
65
-            $lines[] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>";
64
+            $lines[ ] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />";
65
+            $lines[ ] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>";
66 66
         } else {
67
-            $lines[] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />";
67
+            $lines[ ] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />";
68 68
         }
69 69
 
70 70
         return implode("\r\n", $lines);
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
                 return '';
107 107
             }
108 108
         }
109
-        $lines = [];
109
+        $lines = [ ];
110 110
         if ($async) {
111
-            $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>";
112
-            $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>";
111
+            $lines[ ] = "<script type=\"module\" src=\"{$modernModule}\"></script>";
112
+            $lines[ ] = "<script nomodule src=\"{$legacyModule}\"></script>";
113 113
         } else {
114
-            $lines[] = "<script src=\"{$legacyModule}\"></script>";
114
+            $lines[ ] = "<script src=\"{$legacyModule}\"></script>";
115 115
         }
116 116
 
117 117
         return implode("\r\n", $lines);
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
         $module = null;
162 162
         // Determine whether we should use the devServer for HMR or not
163 163
         $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
164
-        $isHot = ($devMode && $config['useDevServer']);
164
+        $isHot = ($devMode && $config[ 'useDevServer' ]);
165 165
         // Get the manifest file
166 166
         $manifest = self::getManifestFile($config, $isHot, $type);
167 167
         if ($manifest !== null) {
168 168
             // Make sure it exists in the manifest
169
-            if (empty($manifest[$moduleName])) {
169
+            if (empty($manifest[ $moduleName ])) {
170 170
                 self::reportError(Craft::t(
171 171
                     'retour',
172 172
                     'Module does not exist in the manifest: {moduleName}',
173
-                    ['moduleName' => $moduleName]
173
+                    [ 'moduleName' => $moduleName ]
174 174
                 ), $soft);
175 175
 
176 176
                 return null;
177 177
             }
178
-            $module = $manifest[$moduleName];
178
+            $module = $manifest[ $moduleName ];
179 179
             $prefix = $isHot
180
-                ? $config['devServer']['publicPath']
181
-                : $config['server']['publicPath'];
180
+                ? $config[ 'devServer' ][ 'publicPath' ]
181
+                : $config[ 'server' ][ 'publicPath' ];
182 182
             // If the module isn't a full URL, prefix it
183 183
             if (!UrlHelper::isAbsoluteUrl($module)) {
184 184
                 $module = self::combinePaths($prefix, $module);
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
         // Try to get the manifest
213 213
         while ($manifest === null) {
214 214
             $manifestPath = $isHot
215
-                ? $config['devServer']['manifestPath']
216
-                : $config['server']['manifestPath'];
215
+                ? $config[ 'devServer' ][ 'manifestPath' ]
216
+                : $config[ 'server' ][ 'manifestPath' ];
217 217
             // Normalize the path
218
-            $path = self::combinePaths($manifestPath, $config['manifest'][$type]);
218
+            $path = self::combinePaths($manifestPath, $config[ 'manifest' ][ $type ]);
219 219
             $manifest = self::getJsonFileFromUri($path);
220 220
             // If the manifest isn't found, and it was hot, fall back on non-hot
221 221
             if ($manifest === null) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
                 self::reportError(Craft::t(
224 224
                     'retour',
225 225
                     'Manifest file not found at: {manifestPath}',
226
-                    ['manifestPath' => $manifestPath]
226
+                    [ 'manifestPath' => $manifestPath ]
227 227
                 ), true);
228 228
                 if ($isHot) {
229 229
                     // Try again, but not with home module replacement
@@ -282,14 +282,14 @@  discard block
 block discarded – undo
282 282
     protected static function getJsonFileContents(string $path)
283 283
     {
284 284
         // Return the memoized manifest if it exists
285
-        if (!empty(self::$files[$path])) {
286
-            return self::$files[$path];
285
+        if (!empty(self::$files[ $path ])) {
286
+            return self::$files[ $path ];
287 287
         }
288 288
         // Create the dependency tags
289 289
         $dependency = new TagDependency([
290 290
             'tags' => [
291 291
                 self::CACHE_TAG,
292
-                self::CACHE_TAG.$path,
292
+                self::CACHE_TAG . $path,
293 293
             ],
294 294
         ]);
295 295
         // Set the cache duration based on devMode
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
         // Get the result from the cache, or parse the file
300 300
         $cache = Craft::$app->getCache();
301 301
         $file = $cache->getOrSet(
302
-            self::CACHE_KEY.$path,
303
-            function () use ($path) {
302
+            self::CACHE_KEY . $path,
303
+            function() use ($path) {
304 304
                 $result = null;
305 305
                 $string = @file_get_contents($path);
306 306
                 if ($string) {
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
             $cacheDuration,
313 313
             $dependency
314 314
         );
315
-        self::$files[$path] = $file;
315
+        self::$files[ $path ] = $file;
316 316
 
317 317
         return $file;
318 318
     }
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     protected static function combinePaths(string ...$paths): string
328 328
     {
329 329
         $last_key = \count($paths) - 1;
330
-        array_walk($paths, function (&$val, $key) use ($last_key) {
330
+        array_walk($paths, function(&$val, $key) use ($last_key) {
331 331
             switch ($key) {
332 332
                 case 0:
333 333
                     $val = rtrim($val, '/ ');
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $last = array_pop($paths);
346 346
         $paths = array_filter($paths);
347 347
         array_unshift($paths, $first);
348
-        $paths[] = $last;
348
+        $paths[ ] = $last;
349 349
 
350 350
         return implode('/', $paths);
351 351
     }
Please login to merge, or discard this patch.