2016-06-06 02:25:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace CodeInspector;
|
|
|
|
|
2016-06-21 01:30:38 +02:00
|
|
|
class IssueHandler
|
2016-06-06 02:25:16 +02:00
|
|
|
{
|
2016-06-21 01:30:38 +02:00
|
|
|
protected static $errors = [];
|
|
|
|
|
2016-06-10 00:08:25 +02:00
|
|
|
public static function accepts(Issue\CodeIssue $e)
|
2016-06-06 02:25:16 +02:00
|
|
|
{
|
2016-06-10 00:08:25 +02:00
|
|
|
$config = Config::getInstance();
|
|
|
|
|
|
|
|
if ($config->excludeIssueInFile(get_class($e), $e->getFileName())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-17 23:34:52 +02:00
|
|
|
$error_class_name = array_pop(explode('\\', get_class($e)));
|
|
|
|
|
|
|
|
$error_message = $error_class_name . ' - ' . $e->getMessage();
|
|
|
|
|
2016-06-21 01:30:38 +02:00
|
|
|
if ($config->getReportingLevel(get_class($e)) !== Config::REPORT_ERROR) {
|
|
|
|
echo $error_message . PHP_EOL;
|
|
|
|
return false;
|
2016-06-10 20:47:44 +02:00
|
|
|
}
|
|
|
|
|
2016-06-17 23:34:52 +02:00
|
|
|
echo $error_message . PHP_EOL;
|
2016-06-17 01:02:29 +02:00
|
|
|
|
2016-06-21 01:30:38 +02:00
|
|
|
if ($config->stop_on_first_error) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
self::$errors[] = $error_message;
|
|
|
|
|
2016-06-17 01:02:29 +02:00
|
|
|
return true;
|
2016-06-06 02:25:16 +02:00
|
|
|
}
|
2016-06-21 01:30:38 +02:00
|
|
|
|
|
|
|
public static function finish()
|
|
|
|
{
|
|
|
|
if (count(self::$errors)) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2016-06-06 02:25:16 +02:00
|
|
|
}
|