Skip to content
Permalink
Browse files

Fix #1814 - warn about deprected ::class access

  • Loading branch information...
muglug committed Jun 19, 2019
1 parent 0246f60 commit bdf54ae1fa48015c1a8e63006587dde1a19ec1ea
@@ -155,6 +155,23 @@ public static function analyzeClassConst(
}
if ($stmt->name instanceof PhpParser\Node\Identifier && $stmt->name->name === 'class') {
if ($codebase->classExists($fq_class_name)) {
$class_const_storage = $codebase->classlike_storage_provider->get($fq_class_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
}
}
}
$stmt->inferredType = Type::getLiteralClassString($fq_class_name);
if ($codebase->store_node_types) {
@@ -113,6 +113,16 @@ class Foo {
echo Foo::FOO;',
'error_message' => 'DeprecatedClass',
],
'deprecatedClassStringConstant' => [
'<?php
/**
* @deprecated
*/
class Foo {}
echo Foo::class;',
'error_message' => 'DeprecatedClass',
]
];
}

0 comments on commit bdf54ae

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