mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Allow specification of custom autoloaders
This commit is contained in:
parent
c4a222171b
commit
6b3fe14f1e
@ -38,6 +38,12 @@ class Config
|
||||
*/
|
||||
public $throw_exception = false;
|
||||
|
||||
/**
|
||||
* Path to the autoader
|
||||
* @var string|null
|
||||
*/
|
||||
public $autoloader;
|
||||
|
||||
protected $inspect_files;
|
||||
|
||||
protected $base_dir;
|
||||
@ -93,6 +99,10 @@ class Config
|
||||
$config->throw_exception = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml['autoloader'])) {
|
||||
$config->autoloader = (string) $config_xml['autoloader'];
|
||||
}
|
||||
|
||||
if (isset($config_xml->inspectFiles)) {
|
||||
$config->inspect_files = FileFilter::loadFromXML($config_xml->inspectFiles, true);
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ class IssueBuffer
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
|
||||
$issue_type = array_pop(explode('\\', get_class($e)));
|
||||
$fqcn_parts = explode('\\', get_class($e));
|
||||
$issue_type = array_pop($fqcn_parts);
|
||||
|
||||
if (in_array($issue_type, $suppressed_issues)) {
|
||||
return false;
|
||||
@ -29,11 +30,10 @@ class IssueBuffer
|
||||
{
|
||||
$config = Config::getInstance();
|
||||
|
||||
$error_class_name = array_pop(explode('\\', get_class($e)));
|
||||
$fqcn_parts = explode('\\', get_class($e));
|
||||
$issue_type = array_pop($fqcn_parts);
|
||||
|
||||
$error_message = $error_class_name . ' - ' . $e->getMessage();
|
||||
|
||||
$issue_type = array_pop(explode('\\', get_class($e)));
|
||||
$error_message = $issue_type . ' - ' . $e->getMessage();
|
||||
|
||||
$reporting_level = $config->getReportingLevel($issue_type);
|
||||
|
||||
|
@ -90,7 +90,9 @@ class ProjectChecker
|
||||
self::$config = self::getConfigForPath($file_name);
|
||||
}
|
||||
|
||||
$extension = array_pop(explode('.', $file_name));
|
||||
$file_name_parts = explode('.', $file_name);
|
||||
|
||||
$extension = array_pop($file_name_parts);
|
||||
|
||||
$filetype_handlers = self::$config->getFiletypeHandlers();
|
||||
|
||||
@ -129,6 +131,7 @@ class ProjectChecker
|
||||
|
||||
if (file_exists($maybe_path)) {
|
||||
$config = \Psalm\Config::loadFromXML($maybe_path);
|
||||
require_once($dir_path . $config->autoloader);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -149,6 +152,10 @@ class ProjectChecker
|
||||
throw new Exception\ConfigException('Config not found at location ' . $path_to_config);
|
||||
}
|
||||
|
||||
$dir_path = dirname($path_to_config) . '/';
|
||||
|
||||
self::$config = \Psalm\Config::loadFromXML($path_to_config);
|
||||
|
||||
require_once($dir_path . self::$config->autoloader);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user