1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Whitelist suppressed issue types to for template extended params

This commit is contained in:
Sam L 2023-12-24 17:50:57 -05:00
parent 21617c7029
commit a60de4bac8
2 changed files with 21 additions and 1 deletions

View File

@ -350,7 +350,7 @@ final class ClassAnalyzer extends ClassLikeAnalyzer
null,
true,
),
$storage->suppressed_issues + $this->getSuppressedIssues(),
$storage->getSuppressedIssuesForTemplateExtendParams() + $this->getSuppressedIssues(),
);
}
}

View File

@ -10,11 +10,13 @@ use Psalm\Internal\Analyzer\ClassLikeAnalyzer;
use Psalm\Internal\MethodIdentifier;
use Psalm\Internal\Type\TypeAlias\ClassTypeAlias;
use Psalm\Issue\CodeIssue;
use Psalm\Issue\DeprecatedClass;
use Psalm\Type\Atomic\TNamedObject;
use Psalm\Type\Atomic\TTemplateParam;
use Psalm\Type\Union;
use function array_values;
use function in_array;
final class ClassLikeStorage implements HasAttributesInterface
{
@ -550,4 +552,22 @@ final class ClassLikeStorage implements HasAttributesInterface
return false;
}
/**
* @return array<int, string>
*/
public function getSuppressedIssuesForTemplateExtendParams(): array
{
$allowed_issue_types = [
DeprecatedClass::getIssueType(),
];
$suppressed_issues_for_template_extend_params = [];
foreach ($this->suppressed_issues as $offset => $suppressed_issue) {
if (!in_array($suppressed_issue, $allowed_issue_types, true)) {
continue;
}
$suppressed_issues_for_template_extend_params[$offset] = $suppressed_issue;
}
return $suppressed_issues_for_template_extend_params;
}
}