1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +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; 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( $this->checkIntersectionTypes(
$source, $source,
$code_location, $code_location,

View File

@ -140,6 +140,16 @@ class DeprecatedAnnotationTest extends TestCase
echo Foo::class;', echo Foo::class;',
'error_message' => 'DeprecatedClass', 'error_message' => 'DeprecatedClass',
], ],
'deprecatedClassAsParam' => [
'<?php
/**
* @deprecated
*/
class DeprecatedClass{}
function foo(DeprecatedClass $deprecatedClass): void {}',
'error_message' => 'DeprecatedClass',
],
]; ];
} }
} }