mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
Merge pull request #10518 from samlitowitz/issue-10490
Deprecated Template Classes are not ignored by @psalm-suppress DeprecatedClass
This commit is contained in:
commit
17cd6a7968
@ -350,7 +350,7 @@ final class ClassAnalyzer extends ClassLikeAnalyzer
|
||||
null,
|
||||
true,
|
||||
),
|
||||
$this->getSuppressedIssues(),
|
||||
$storage->getSuppressedIssuesForTemplateExtendParams() + $this->getSuppressedIssues(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -551,4 +553,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;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,24 @@ class DeprecatedAnnotationTest extends TestCase
|
||||
public $property;
|
||||
}
|
||||
'],
|
||||
'suppressDeprecatedClassOnTemplateType' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class TheDeprecatedClass {}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*/
|
||||
class TheParentClass {}
|
||||
|
||||
/**
|
||||
* @extends TheParentClass<TheDeprecatedClass>
|
||||
* @psalm-suppress DeprecatedClass
|
||||
*/
|
||||
class TheChildClass extends TheParentClass {}
|
||||
'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user