protected $paths;
/**
- * Constructor.
- *
* @param string|array $paths A path or an array of paths where to look for resources
*/
public function __construct($paths = array())
if ($this->isAbsolutePath($name)) {
if (!file_exists($name)) {
- throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name));
+ throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name), 0, null, array($name));
}
return $name;
}
$paths = array_unique($paths);
- $filepaths = array();
+ $filepaths = $notfound = array();
foreach ($paths as $path) {
if (@file_exists($file = $path.DIRECTORY_SEPARATOR.$name)) {
return $file;
}
$filepaths[] = $file;
+ } else {
+ $notfound[] = $file;
}
}
if (!$filepaths) {
- throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)));
+ throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist (in: %s).', $name, implode(', ', $paths)), 0, null, $notfound);
}
return $filepaths;
*/
private function isAbsolutePath($file)
{
- if ($file[0] === '/' || $file[0] === '\\'
+ if ('/' === $file[0] || '\\' === $file[0]
|| (strlen($file) > 3 && ctype_alpha($file[0])
- && $file[1] === ':'
- && ($file[2] === '\\' || $file[2] === '/')
+ && ':' === $file[1]
+ && ('\\' === $file[2] || '/' === $file[2])
)
|| null !== parse_url($file, PHP_URL_SCHEME)
) {