From 5e124a88484150871ba343b9b9fffd3283060dfb Mon Sep 17 00:00:00 2001 From: Klaus Purer Date: Sat, 7 Dec 2019 16:06:13 +0100 Subject: [PATCH] fix(ruleset): Autoload relative paths correctly to avoid confusion with files from the global include path --- src/Ruleset.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Ruleset.php b/src/Ruleset.php index 6387a6f98f..f1f28397fe 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -356,11 +356,13 @@ public function processRuleset($rulesetPath, $depth=0) } $autoloadPath = (string) $autoload; - if (is_file($autoloadPath) === false) { - $autoloadPath = Util\Common::realPath(dirname($rulesetPath).DIRECTORY_SEPARATOR.$autoloadPath); - } - if ($autoloadPath === false) { + // Try relative autoload paths first. + $relativePath = Util\Common::realPath(dirname($rulesetPath).DIRECTORY_SEPARATOR.$autoloadPath); + + if ($relativePath !== false && is_file($$relativePath) === true) { + $autoloadPath = $relativePath; + } else if (is_file($autoloadPath) === false) { throw new RuntimeException('The specified autoload file "'.$autoload.'" does not exist'); }