Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoload relative paths first to avoid confusion with files from the global include path #2751

Merged
merged 1 commit into from
Dec 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double $ needs to be removed here. I'll do this while merging.

$autoloadPath = $relativePath;
} else if (is_file($autoloadPath) === false) {
throw new RuntimeException('The specified autoload file "'.$autoload.'" does not exist');
}

Expand Down