mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix issues with @psalm-ignore-nullable-return types
This commit is contained in:
parent
65d86d35ad
commit
77a44051c5
@ -161,6 +161,7 @@ class FunctionChecker extends FunctionLikeChecker
|
|||||||
*/
|
*/
|
||||||
public static function replaceTemplateTypes(Type\Union $return_type, array $template_types)
|
public static function replaceTemplateTypes(Type\Union $return_type, array $template_types)
|
||||||
{
|
{
|
||||||
|
$ignore_nullable_issues = $return_type->ignore_nullable_issues;
|
||||||
$type_tokens = Type::tokenize((string)$return_type);
|
$type_tokens = Type::tokenize((string)$return_type);
|
||||||
|
|
||||||
foreach ($type_tokens as &$type_token) {
|
foreach ($type_tokens as &$type_token) {
|
||||||
@ -169,7 +170,11 @@ class FunctionChecker extends FunctionLikeChecker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Type::parseString(implode('', $type_tokens));
|
$result_type = Type::parseString(implode('', $type_tokens));
|
||||||
|
|
||||||
|
$result_type->ignore_nullable_issues = $ignore_nullable_issues;
|
||||||
|
|
||||||
|
return $result_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -737,7 +737,8 @@ class AssignmentChecker
|
|||||||
if (!TypeChecker::isContainedBy(
|
if (!TypeChecker::isContainedBy(
|
||||||
$assignment_value_type,
|
$assignment_value_type,
|
||||||
$class_property_type,
|
$class_property_type,
|
||||||
$file_checker
|
$file_checker,
|
||||||
|
$assignment_value_type->ignore_nullable_issues
|
||||||
)) {
|
)) {
|
||||||
if (IssueBuffer::accepts(
|
if (IssueBuffer::accepts(
|
||||||
new InvalidPropertyAssignment(
|
new InvalidPropertyAssignment(
|
||||||
|
@ -280,6 +280,10 @@ class Union
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($new_type && $new_type->ignore_nullable_issues) {
|
||||||
|
$this->ignore_nullable_issues = true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($old_type->types as $old_type_part) {
|
foreach ($old_type->types as $old_type_part) {
|
||||||
$this->removeType($old_type_part->getKey());
|
$this->removeType($old_type_part->getKey());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user