Skip to content
Permalink
Browse files

Fix #1803 - complain about DeprecatedClass when using its constants

  • Loading branch information...
muglug committed Jun 18, 2019
1 parent 22ae114 commit 10613192c93e360ede7083b3e9e6504b0de69c56
@@ -10,6 +10,7 @@
use Psalm\Codebase;
use Psalm\CodeLocation;
use Psalm\Context;
use Psalm\Issue\DeprecatedClass;
use Psalm\Issue\DeprecatedConstant;
use Psalm\Issue\InaccessibleClassConstant;
use Psalm\Issue\ParentNotFound;
@@ -293,7 +294,18 @@ public static function analyzeClassConst(
$class_const_storage = $codebase->classlike_storage_provider->get($fq_class_name);
if (isset($class_const_storage->deprecated_constants[$stmt->name->name])) {
if ($class_const_storage->deprecated) {
if (IssueBuffer::accepts(
new DeprecatedClass(
'Class ' . $fq_class_name . ' is deprecated',
new CodeLocation($statements_analyzer->getSource(), $stmt),
$fq_class_name
),
$statements_analyzer->getSuppressedIssues()
)) {
// fall through
}
} elseif (isset($class_const_storage->deprecated_constants[$stmt->name->name])) {
if (IssueBuffer::accepts(
new DeprecatedConstant(
'Constant ' . $const_id . ' is deprecated',
@@ -102,6 +102,18 @@ class A{
$a->foo = 5;',
'error_message' => 'DeprecatedProperty',
],
'deprecatedClassConstant' => [
'<?php
/**
* @deprecated
*/
class Foo {
public const FOO = 5;
}
echo Foo::FOO;',
'error_message' => 'DeprecatedClass',
]
];
}
}

0 comments on commit 1061319

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