1
0
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:
Brown 2019-08-22 11:21:31 -04:00
parent 855ab359fe
commit 4fcbc0fdad
2 changed files with 27 additions and 0 deletions

View File

@ -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,

View File

@ -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',
],
];
}
}