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:
parent
855ab359fe
commit
4fcbc0fdad
@ -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,
|
||||||
|
@ -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',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user