Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
[zendframework/zendframework#4574] Only run stream_resolve_include_pa…
Browse files Browse the repository at this point in the history
…th when necessary

- i.e., when `file_exists()` fails
- Raise an exception if it still cannot be found
  • Loading branch information
weierophinney committed Jun 28, 2013
1 parent 632d223 commit 5012106
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ class Factory
*/
public static function fromFile($filename, $returnConfigObject = false)
{
$fromIncludePath = stream_resolve_include_path($filename);
if ($fromIncludePath) {
$filepath = $filename;
if (!file_exists($filename)) {
$fromIncludePath = stream_resolve_include_path($filename);
if (!$fromIncludePath) {
throw new Exception\RuntimeException(sprintf(
'Filename "%s" cannot be found relative to the working directory or the include_path ("%s")',
$filename,
get_include_path()
));
}
$filepath = $fromIncludePath;
} else {
$filepath = $filename;
}

$pathinfo = pathinfo($filepath);
Expand Down

0 comments on commit 5012106

Please sign in to comment.