mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #2028 - warn when using deprecated class in function signature
This commit is contained in:
parent
855ab359fe
commit
4fcbc0fdad
@ -169,6 +169,23 @@ class TNamedObject extends Atomic
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($codebase->classlike_storage_provider->has($this->value)) {
|
||||
$class_storage = $codebase->classlike_storage_provider->get($this->value);
|
||||
|
||||
if ($class_storage->deprecated) {
|
||||
if (\Psalm\IssueBuffer::accepts(
|
||||
new \Psalm\Issue\DeprecatedClass(
|
||||
'Class ' . $this->value . ' is marked as deprecated',
|
||||
$code_location,
|
||||
$this->value
|
||||
),
|
||||
$source->getSuppressedIssues()
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->checkIntersectionTypes(
|
||||
$source,
|
||||
$code_location,
|
||||
|
@ -140,6 +140,16 @@ class DeprecatedAnnotationTest extends TestCase
|
||||
echo Foo::class;',
|
||||
'error_message' => 'DeprecatedClass',
|
||||
],
|
||||
'deprecatedClassAsParam' => [
|
||||
'<?php
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
class DeprecatedClass{}
|
||||
|
||||
function foo(DeprecatedClass $deprecatedClass): void {}',
|
||||
'error_message' => 'DeprecatedClass',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user