@@ -71,12 +71,12 @@ discard block |
||
| 71 | 71 | if ($legacyModule === null) { |
| 72 | 72 | return ''; |
| 73 | 73 | } |
| 74 | - $lines = []; |
|
| 74 | + $lines = [ ]; |
|
| 75 | 75 | if ($async) { |
| 76 | - $lines[] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
| 77 | - $lines[] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
| 76 | + $lines[ ] = "<link rel=\"preload\" href=\"{$legacyModule}\" as=\"style\" onload=\"this.onload=null;this.rel='stylesheet'\" />"; |
|
| 77 | + $lines[ ] = "<noscript><link rel=\"stylesheet\" href=\"{$legacyModule}\"></noscript>"; |
|
| 78 | 78 | } else { |
| 79 | - $lines[] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
| 79 | + $lines[ ] = "<link rel=\"stylesheet\" href=\"{$legacyModule}\" />"; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return implode("\r\n", $lines); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | { |
| 92 | 92 | $result = self::getFile($path); |
| 93 | 93 | if ($result) { |
| 94 | - $result = "<style>\r\n".$result."</style>\r\n"; |
|
| 94 | + $result = "<style>\r\n" . $result . "</style>\r\n"; |
|
| 95 | 95 | return $result; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | return ''; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - $lines = []; |
|
| 137 | + $lines = [ ]; |
|
| 138 | 138 | if ($async) { |
| 139 | - $lines[] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
| 140 | - $lines[] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
| 139 | + $lines[ ] = "<script type=\"module\" src=\"{$modernModule}\"></script>"; |
|
| 140 | + $lines[ ] = "<script nomodule src=\"{$legacyModule}\"></script>"; |
|
| 141 | 141 | } else { |
| 142 | - $lines[] = "<script src=\"{$legacyModule}\"></script>"; |
|
| 142 | + $lines[ ] = "<script src=\"{$legacyModule}\"></script>"; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | return implode("\r\n", $lines); |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | $module = self::getModuleEntry($config, $moduleName, $type, $soft); |
| 191 | 191 | if ($module !== null) { |
| 192 | 192 | $prefix = self::$isHot |
| 193 | - ? $config['devServer']['publicPath'] |
|
| 194 | - : $config['server']['publicPath']; |
|
| 193 | + ? $config[ 'devServer' ][ 'publicPath' ] |
|
| 194 | + : $config[ 'server' ][ 'publicPath' ]; |
|
| 195 | 195 | // If the module isn't a full URL, prefix it |
| 196 | 196 | if (!UrlHelper::isAbsoluteUrl($module)) { |
| 197 | 197 | $module = self::combinePaths($prefix, $module); |
@@ -232,19 +232,19 @@ discard block |
||
| 232 | 232 | $manifest = self::getManifestFile($config, $type); |
| 233 | 233 | if ($manifest !== null) { |
| 234 | 234 | // Make sure it exists in the manifest |
| 235 | - if (empty($manifest[$moduleName])) { |
|
| 235 | + if (empty($manifest[ $moduleName ])) { |
|
| 236 | 236 | // Don't report errors for any files in SUPPRESS_ERRORS_FOR_MODULES |
| 237 | 237 | if (!in_array($moduleName, self::SUPPRESS_ERRORS_FOR_MODULES)) { |
| 238 | 238 | self::reportError(Craft::t( |
| 239 | 239 | 'retour', |
| 240 | 240 | 'Module does not exist in the manifest: {moduleName}', |
| 241 | - ['moduleName' => $moduleName] |
|
| 241 | + [ 'moduleName' => $moduleName ] |
|
| 242 | 242 | ), $soft); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | return null; |
| 246 | 246 | } |
| 247 | - $module = $manifest[$moduleName]; |
|
| 247 | + $module = $manifest[ $moduleName ]; |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | return $module; |
@@ -264,14 +264,14 @@ discard block |
||
| 264 | 264 | $manifest = null; |
| 265 | 265 | // Determine whether we should use the devServer for HMR or not |
| 266 | 266 | $devMode = Craft::$app->getConfig()->getGeneral()->devMode; |
| 267 | - self::$isHot = ($devMode && $config['useDevServer']); |
|
| 267 | + self::$isHot = ($devMode && $config[ 'useDevServer' ]); |
|
| 268 | 268 | // Try to get the manifest |
| 269 | 269 | while ($manifest === null) { |
| 270 | 270 | $manifestPath = self::$isHot |
| 271 | - ? $config['devServer']['manifestPath'] |
|
| 272 | - : $config['server']['manifestPath']; |
|
| 271 | + ? $config[ 'devServer' ][ 'manifestPath' ] |
|
| 272 | + : $config[ 'server' ][ 'manifestPath' ]; |
|
| 273 | 273 | // Normalize the path |
| 274 | - $path = self::combinePaths($manifestPath, $config['manifest'][$type]); |
|
| 274 | + $path = self::combinePaths($manifestPath, $config[ 'manifest' ][ $type ]); |
|
| 275 | 275 | $manifest = self::getJsonFile($path); |
| 276 | 276 | // If the manifest isn't found, and it was hot, fall back on non-hot |
| 277 | 277 | if ($manifest === null) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | self::reportError(Craft::t( |
| 280 | 280 | 'retour', |
| 281 | 281 | 'Manifest file not found at: {manifestPath}', |
| 282 | - ['manifestPath' => $manifestPath] |
|
| 282 | + [ 'manifestPath' => $manifestPath ] |
|
| 283 | 283 | ), true); |
| 284 | 284 | if (self::$isHot) { |
| 285 | 285 | // Try again, but not with home module replacement |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | if ($path !== null) { |
| 324 | 324 | $path = self::combinePaths( |
| 325 | - $config['localFiles']['basePath'], |
|
| 325 | + $config[ 'localFiles' ][ 'basePath' ], |
|
| 326 | 326 | $path |
| 327 | 327 | ); |
| 328 | 328 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | protected static function getJsonFile(string $path) |
| 343 | 343 | { |
| 344 | - return self::getFileFromUri($path, [self::class, 'jsonFileDecode']); |
|
| 344 | + return self::getFileFromUri($path, [ self::class, 'jsonFileDecode' ]); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -395,14 +395,14 @@ discard block |
||
| 395 | 395 | protected static function getFileContents(string $path, callable $callback = null) |
| 396 | 396 | { |
| 397 | 397 | // Return the memoized manifest if it exists |
| 398 | - if (!empty(self::$files[$path])) { |
|
| 399 | - return self::$files[$path]; |
|
| 398 | + if (!empty(self::$files[ $path ])) { |
|
| 399 | + return self::$files[ $path ]; |
|
| 400 | 400 | } |
| 401 | 401 | // Create the dependency tags |
| 402 | 402 | $dependency = new TagDependency([ |
| 403 | 403 | 'tags' => [ |
| 404 | 404 | self::CACHE_TAG, |
| 405 | - self::CACHE_TAG.$path, |
|
| 405 | + self::CACHE_TAG . $path, |
|
| 406 | 406 | ], |
| 407 | 407 | ]); |
| 408 | 408 | // Set the cache duration based on devMode |
@@ -412,8 +412,8 @@ discard block |
||
| 412 | 412 | // Get the result from the cache, or parse the file |
| 413 | 413 | $cache = Craft::$app->getCache(); |
| 414 | 414 | $file = $cache->getOrSet( |
| 415 | - self::CACHE_KEY.$path, |
|
| 416 | - function () use ($path, $callback) { |
|
| 415 | + self::CACHE_KEY . $path, |
|
| 416 | + function() use ($path, $callback) { |
|
| 417 | 417 | $result = null; |
| 418 | 418 | $contents = @file_get_contents($path); |
| 419 | 419 | if ($contents) { |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | $cacheDuration, |
| 429 | 429 | $dependency |
| 430 | 430 | ); |
| 431 | - self::$files[$path] = $file; |
|
| 431 | + self::$files[ $path ] = $file; |
|
| 432 | 432 | |
| 433 | 433 | return $file; |
| 434 | 434 | } |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | protected static function combinePaths(string ...$paths): string |
| 444 | 444 | { |
| 445 | 445 | $last_key = \count($paths) - 1; |
| 446 | - array_walk($paths, function (&$val, $key) use ($last_key) { |
|
| 446 | + array_walk($paths, function(&$val, $key) use ($last_key) { |
|
| 447 | 447 | switch ($key) { |
| 448 | 448 | case 0: |
| 449 | 449 | $val = rtrim($val, '/ '); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $last = array_pop($paths); |
| 462 | 462 | $paths = array_filter($paths); |
| 463 | 463 | array_unshift($paths, $first); |
| 464 | - $paths[] = $last; |
|
| 464 | + $paths[ ] = $last; |
|
| 465 | 465 | |
| 466 | 466 | return implode('/', $paths); |
| 467 | 467 | } |