Skip to content

Commit 5e124a8

Browse files
committed
fix(ruleset): Autoload relative paths correctly to avoid confusion with files from the global include path
1 parent 2ecd8dc commit 5e124a8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Ruleset.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,13 @@ public function processRuleset($rulesetPath, $depth=0)
356356
}
357357

358358
$autoloadPath = (string) $autoload;
359-
if (is_file($autoloadPath) === false) {
360-
$autoloadPath = Util\Common::realPath(dirname($rulesetPath).DIRECTORY_SEPARATOR.$autoloadPath);
361-
}
362359

363-
if ($autoloadPath === false) {
360+
// Try relative autoload paths first.
361+
$relativePath = Util\Common::realPath(dirname($rulesetPath).DIRECTORY_SEPARATOR.$autoloadPath);
362+
363+
if ($relativePath !== false && is_file($$relativePath) === true) {
364+
$autoloadPath = $relativePath;
365+
} else if (is_file($autoloadPath) === false) {
364366
throw new RuntimeException('The specified autoload file "'.$autoload.'" does not exist');
365367
}
366368

0 commit comments

Comments
 (0)