public static function autoload($className)
{
if (substr($className, 0, 4) === 'PHP_') {
$newClassName = substr($className, 4);
} else {
$newClassName = $className;
}
$path = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $newClassName) . '.php';
if (is_file(dirname(__FILE__) . DIRECTORY_SEPARATOR . $path) === true) {
// Check standard file locations based on class name.
include dirname(__FILE__) . DIRECTORY_SEPARATOR . $path;
return;
} else {
// Check for included sniffs.
$installedPaths = PHP_CodeSniffer::getInstalledStandardPaths();
foreach ($installedPaths as $installedPath) {
if (is_file($installedPath . DIRECTORY_SEPARATOR . $path) === true) {
include $installedPath . DIRECTORY_SEPARATOR . $path;
return;
}
}
// Check standard file locations based on the loaded rulesets.
foreach (self::$rulesetDirs as $rulesetDir) {
if (is_file(dirname($rulesetDir) . DIRECTORY_SEPARATOR . $path) === true) {
include_once dirname($rulesetDir) . DIRECTORY_SEPARATOR . $path;
return;
}
}
}
//end if
// Everything else.
@(include $path);
}