1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Improve error messages

This commit is contained in:
Matthew Brown 2016-06-17 17:34:52 -04:00
parent af3577aeee
commit 4b0c37f8b4
3 changed files with 9 additions and 9 deletions

View File

@ -78,7 +78,7 @@ class ClassMethodChecker extends FunctionChecker
if (ExceptionHandler::accepts(
new InvalidReturnType(
'No return type was found for method ' . $method_id . ' but return type ' . $declared_return_type . ' was expected',
'No return type was found for method ' . $method_id . ' but return type \'' . $declared_return_type . '\' was expected',
$this->_file_name,
$this->_function->getLine()
)
@ -145,7 +145,7 @@ class ClassMethodChecker extends FunctionChecker
if ($truly_different) {
if (ExceptionHandler::accepts(
new InvalidReturnType(
'The given return type ' . $declared_return_type . ' for ' . $method_id . ' is incorrect, got ' . $inferred_return_type,
'The given return type \'' . $declared_return_type . '\' for ' . $method_id . ' is incorrect, got \'' . $inferred_return_type . '\'',
$this->_file_name,
$this->_function->getLine()
)
@ -251,7 +251,7 @@ class ClassMethodChecker extends FunctionChecker
// maybe it's an old-timey constructor
$absolute_class = explode('::', $method_id)[0];
$class_name = array_pop(explode('\'', $absolute_class));
$class_name = array_pop(explode('\\', $absolute_class));
$alt_method_id = $absolute_class . '::' . $class_name;

View File

@ -12,11 +12,15 @@ class ExceptionHandler
return false;
}
$error_class_name = array_pop(explode('\\', get_class($e)));
$error_message = $error_class_name . ' - ' . $e->getMessage();
if ($config->stop_on_error) {
throw new CodeException($e->getMessage());
throw new CodeException($error_message);
}
echo $e->getMessage() . PHP_EOL;
echo $error_message . PHP_EOL;
return true;
}

View File

@ -4,8 +4,4 @@ namespace CodeInspector\Issue;
abstract class CodeError extends CodeIssue
{
public function getMessage()
{
return 'Error: ' . parent::getMessage();
}
}