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

Support PHP7 return types

This commit is contained in:
Matthew Brown 2016-10-18 21:54:08 -04:00
parent 6b4039aae3
commit 98b4029ebd
3 changed files with 15 additions and 1 deletions

View File

@ -175,6 +175,10 @@ class FunctionChecker extends FunctionLikeChecker
$this->suppressed_issues = $docblock_info['suppress'];
if (isset($function->returnType)) {
$return_type = Type::parseString($function->returnType);
}
if ($config->use_docblock_types) {
if ($docblock_info['return_type']) {
$return_type =

View File

@ -249,6 +249,10 @@ class MethodChecker extends FunctionLikeChecker
self::$method_suppress[$method_id] = [];
if (isset($method->returnType)) {
$return_type = Type::parseString($method->returnType);
}
if ($doc_comment) {
$docblock_info = CommentChecker::extractDocblockInfo((string)$doc_comment);

View File

@ -4364,7 +4364,13 @@ class StatementsChecker
return false;
}
$stmt->inferredType = FunctionChecker::getReturnTypeFromCallMap($method_id, $stmt->args, $this->checked_file_name, $stmt->getLine(), $this->suppressed_issues);
try {
$stmt->inferredType = FunctionChecker::getFunctionReturnTypes($method_id, $this->checked_file_name);
}
catch (\InvalidArgumentException $e) {
$stmt->inferredType = FunctionChecker::getReturnTypeFromCallMap($method_id, $stmt->args, $this->checked_file_name, $stmt->getLine(), $this->suppressed_issues);
}
}
if ($stmt->name instanceof PhpParser\Node\Name && $stmt->name->parts === ['get_class'] && $stmt->args) {