diff --git a/src/Symfony/Component/Config/FileLocator.php b/src/Symfony/Component/Config/FileLocator.php index 71bb5ab0ba..c224833f26 100644 --- a/src/Symfony/Component/Config/FileLocator.php +++ b/src/Symfony/Component/Config/FileLocator.php @@ -47,15 +47,15 @@ class FileLocator implements FileLocatorInterface return $name; } - $filepaths = array(); - if (null !== $currentPath && file_exists($file = $currentPath.DIRECTORY_SEPARATOR.$name)) { - if (true === $first) { - return $file; - } - $filepaths[] = $file; + $paths = $this->paths; + + if (null !== $currentPath) { + array_unshift($paths, $currentPath); } - foreach ($this->paths as $path) { + $filepaths = array(); + + foreach ($paths as $path) { if (file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) { if (true === $first) { return $file; @@ -65,7 +65,7 @@ class FileLocator implements FileLocatorInterface } if (!$filepaths) { - throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s%s).', $name, null !== $currentPath ? $currentPath.', ' : '', implode(', ', $this->paths))); + throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths))); } return array_values(array_unique($filepaths));