mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
parent
5783611366
commit
fd9e783a37
@ -90,21 +90,32 @@ class AssignmentChecker
|
||||
}
|
||||
|
||||
foreach ($var_comments as $var_comment) {
|
||||
$var_comment_type = ExpressionChecker::fleshOutType(
|
||||
$statements_checker->getFileChecker()->project_checker,
|
||||
$var_comment->type,
|
||||
$context->self,
|
||||
$context->self
|
||||
);
|
||||
try {
|
||||
$var_comment_type = ExpressionChecker::fleshOutType(
|
||||
$statements_checker->getFileChecker()->project_checker,
|
||||
$var_comment->type,
|
||||
$context->self,
|
||||
$context->self
|
||||
);
|
||||
|
||||
$var_comment_type->setFromDocblock();
|
||||
$var_comment_type->setFromDocblock();
|
||||
|
||||
if (!$var_comment->var_id || $var_comment->var_id === $var_id) {
|
||||
$comment_type = $var_comment_type;
|
||||
continue;
|
||||
if (!$var_comment->var_id || $var_comment->var_id === $var_id) {
|
||||
$comment_type = $var_comment_type;
|
||||
continue;
|
||||
}
|
||||
|
||||
$context->vars_in_scope[$var_comment->var_id] = $var_comment_type;
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidDocblock(
|
||||
(string)$e->getMessage(),
|
||||
new CodeLocation($statements_checker->getSource(), $assign_var)
|
||||
)
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
|
||||
$context->vars_in_scope[$var_comment->var_id] = $var_comment_type;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -758,7 +758,7 @@ class ExpressionChecker
|
||||
|
||||
if ($return_type_lc === 'static' || $return_type_lc === '$this') {
|
||||
if (!$static_class) {
|
||||
throw new \InvalidArgumentException(
|
||||
throw new \UnexpectedValueException(
|
||||
'Cannot handle ' . $return_type->value . ' when $static_class is empty'
|
||||
);
|
||||
}
|
||||
@ -766,7 +766,7 @@ class ExpressionChecker
|
||||
$return_type->value = $static_class;
|
||||
} elseif ($return_type_lc === 'self') {
|
||||
if (!$self_class) {
|
||||
throw new \InvalidArgumentException(
|
||||
throw new \UnexpectedValueException(
|
||||
'Cannot handle ' . $return_type->value . ' when $self_class is empty'
|
||||
);
|
||||
}
|
||||
|
@ -1439,6 +1439,12 @@ class AnnotationTest extends TestCase
|
||||
'error_message' => 'UndefinedClass',
|
||||
'error_levels' => ['LessSpecificReturnStatement', 'MoreSpecificReturnType'],
|
||||
],
|
||||
'badStaticVar' => [
|
||||
'<?php
|
||||
/** @var static */
|
||||
$a = new stdClass();',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user