1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00

Catch bad docblock issue

This commit is contained in:
Matthew Brown 2016-10-28 10:54:20 -04:00
parent 0b0a5ff0e8
commit b627bdf9c6
2 changed files with 98 additions and 62 deletions

View File

@ -167,8 +167,26 @@ class FunctionChecker extends FunctionLikeChecker
$config = Config::getInstance();
$return_type = null;
$docblock_info = CommentChecker::extractDocblockInfo((string)$function->getDocComment());
$docblock_info = null;
$this->suppressed_issues = [];
try {
$docblock_info = CommentChecker::extractDocblockInfo((string)$function->getDocComment());
}
catch (\Psalm\Exception\DocblockParseException $e) {
if (IssueBuffer::accepts(
new InvalidDocblock(
'Invalid type passed in docblock for ' . $this->getMethodId(),
$this->getCheckedFileName(),
$function->getLine()
)
)) {
return false;
}
}
if ($docblock_info) {
if ($docblock_info['deprecated']) {
self::$deprecated_functions[$file_name][$function_id] = true;
}
@ -209,6 +227,7 @@ class FunctionChecker extends FunctionLikeChecker
);
}
}
}
self::$function_return_types[$file_name][$function_id] = $return_type ?: false;
}

View File

@ -260,8 +260,24 @@ class MethodChecker extends FunctionLikeChecker
}
if ($doc_comment) {
$docblock_info = CommentChecker::extractDocblockInfo((string)$doc_comment);
$docblock_info = null;
try {
$docblock_info = CommentChecker::extractDocblockInfo((string)$doc_comment);
}
catch (\Psalm\Exception\DocblockParseException $e) {
if (IssueBuffer::accepts(
new InvalidDocblock(
'Invalid type passed in docblock for ' . $this->getMethodId(),
$this->getCheckedFileName(),
$function->getLine()
)
)) {
return false;
}
}
if ($docblock_info) {
if ($docblock_info['deprecated']) {
self::$deprecated_methods[$method_id] = true;
}
@ -296,6 +312,7 @@ class MethodChecker extends FunctionLikeChecker
}
}
}
}
self::$method_return_types[$method_id] = $return_type;
}