Skip to content
Permalink
Browse files

Fix #2028 - warn when using deprecated class in function signature

  • Loading branch information...
muglug committed Aug 22, 2019
1 parent 855ab35 commit 4fcbc0fdad4aff45f0c41fd807d2d284602b0b2b
Showing with 27 additions and 0 deletions.
  1. +17 −0 src/Psalm/Type/Atomic/TNamedObject.php
  2. +10 −0 tests/DeprecatedAnnotationTest.php
@@ -169,6 +169,23 @@ public function check(
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 Foo {}
echo Foo::class;',
'error_message' => 'DeprecatedClass',
],
'deprecatedClassAsParam' => [
'<?php
/**
* @deprecated
*/
class DeprecatedClass{}
function foo(DeprecatedClass $deprecatedClass): void {}',
'error_message' => 'DeprecatedClass',
],
];
}
}

0 comments on commit 4fcbc0f

Please sign in to comment.
You can’t perform that action at this time.