diff --git a/src/Assetic/Asset/FileAsset.php b/src/Assetic/Asset/FileAsset.php index b1ebe92e4..a38f032d3 100644 --- a/src/Assetic/Asset/FileAsset.php +++ b/src/Assetic/Asset/FileAsset.php @@ -1,5 +1,6 @@ source, $this->getVars(), $this->getValues()); if (!is_file($source)) { - throw new RuntimeException(sprintf('The source file "%s" does not exist.', $source)); + throw new RuntimeException(sprintf('The source file "%s" does not exist.', File::nicePath($source))); } $this->doLoad(file_get_contents($source), $additionalFilter); @@ -71,7 +72,7 @@ public function getLastModified() $source = VarUtils::resolve($this->source, $this->getVars(), $this->getValues()); if (!is_file($source)) { - throw new RuntimeException(sprintf('The source file "%s" does not exist.', $source)); + throw new RuntimeException(sprintf('The source file "%s" does not exist.', File::nicePath($source))); } return filemtime($source); diff --git a/src/Assetic/Combiner.php b/src/Assetic/Combiner.php index 4cfe94f6f..412283810 100644 --- a/src/Assetic/Combiner.php +++ b/src/Assetic/Combiner.php @@ -1,10 +1,10 @@ getFilters(File::extension($asset), $production); - $path = file_exists($asset) - ? $asset - : (File::symbolizePath($asset, null) ?: $this->localPath . $asset); + + $path = File::symbolizePath($asset); + if (!file_exists($path) && file_exists($this->localPath . $asset)) { + $path = $this->localPath . $asset; + } $files[] = new FileAsset($path, $filters, base_path()); $filesSalt .= $this->localPath . $asset; } - $filesSalt = md5($filesSalt); + $filesSalt = md5($filesSalt); $collection = new AssetCollection($files, [], $filesSalt); $collection->setTargetPath($targetPath); diff --git a/src/Assetic/Factory/AssetFactory.php b/src/Assetic/Factory/AssetFactory.php index 61efefa73..43607bf54 100644 --- a/src/Assetic/Factory/AssetFactory.php +++ b/src/Assetic/Factory/AssetFactory.php @@ -257,7 +257,7 @@ public function generateAssetName($inputs, $filters, $options = []) public function getLastModified(AssetInterface $asset) { $mtime = 0; - foreach ($asset instanceof AssetCollectionInterface ? $asset : array($asset) as $leaf) { + foreach ($asset instanceof AssetCollectionInterface ? $asset : [$asset] as $leaf) { $mtime = max($mtime, $leaf->getLastModified()); if (!$filters = $leaf->getFilters()) { @@ -272,7 +272,7 @@ public function getLastModified(AssetInterface $asset) continue; } - // extract children from leaf after running all preceeding filters + // Extract children from leaf after running all preceding filters $clone = clone $leaf; $clone->clearFilters(); foreach (array_slice($prevFilters, 0, -1) as $prevFilter) { @@ -298,7 +298,7 @@ public function getLastModified(AssetInterface $asset) * * A glob: If the string contains a "*" it will be interpreted as a glob * * A path: Otherwise the string is interpreted as a filesystem path * - * Both globs and paths will be absolutized using the current root directory. + * Both globs and paths will be absolute using the current root directory. * * @param string $input An input string * @param array $options An array of options @@ -384,7 +384,7 @@ private static function isAbsolutePath($path) } /** - * Loops through the root directories and returns the first match. + * findRootDir loops through the root directories and returns the first match. * * @param string $path An absolute path * @param array $roots An array of root directories diff --git a/src/Assetic/Traits/HasDeepHasher.php b/src/Assetic/Traits/HasDeepHasher.php index 3989b18ae..bc0e04ae2 100644 --- a/src/Assetic/Traits/HasDeepHasher.php +++ b/src/Assetic/Traits/HasDeepHasher.php @@ -29,9 +29,16 @@ public function getDeepHashFromAssets($assets) { $key = ''; - $assetFiles = array_map(function ($file) { - return file_exists($file) ? $file : (File::symbolizePath($file, null) ?: $this->localPath . $file); - }, $assets); + $assetFiles = []; + foreach ($assets as $file) { + $path = File::symbolizePath($file); + if (file_exists($path)) { + $assetFiles[] = $path; + } + elseif (file_exists($this->localPath . $path)) { + $assetFiles[] = $this->localPath . $path; + } + } foreach ($assetFiles as $file) { $filters = $this->getFilters(File::extension($file));