mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #7025 from orklah/6256
flag DeprecatedProperty on static fetch
This commit is contained in:
commit
466137a4c4
@ -2,6 +2,8 @@
|
||||
namespace Psalm\Internal\Analyzer\Statements\Expression\Fetch;
|
||||
|
||||
use PhpParser;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
@ -479,10 +481,13 @@ class AtomicPropertyFetchAnalyzer
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PropertyFetch|StaticPropertyFetch $stmt
|
||||
*/
|
||||
public static function checkPropertyDeprecation(
|
||||
string $prop_name,
|
||||
string $declaring_property_class,
|
||||
PhpParser\Node\Expr\PropertyFetch $stmt,
|
||||
PhpParser\Node\Expr $stmt,
|
||||
StatementsAnalyzer $statements_analyzer
|
||||
): void {
|
||||
$property_id = $declaring_property_class . '::$' . $prop_name;
|
||||
|
@ -261,6 +261,13 @@ class StaticPropertyFetchAnalyzer
|
||||
return false;
|
||||
}
|
||||
|
||||
AtomicPropertyFetchAnalyzer::checkPropertyDeprecation(
|
||||
$prop_name,
|
||||
$declaring_property_class,
|
||||
$stmt,
|
||||
$statements_analyzer
|
||||
);
|
||||
|
||||
$class_storage = $codebase->classlike_storage_provider->get($declaring_property_class);
|
||||
$property = $class_storage->properties[$prop_name];
|
||||
|
||||
|
@ -232,6 +232,21 @@ class DeprecatedAnnotationTest extends TestCase
|
||||
function foo(DeprecatedClass $deprecatedClass): void {}',
|
||||
'error_message' => 'DeprecatedClass',
|
||||
],
|
||||
'deprecatedStaticPropertyFetch' => [
|
||||
'<?php
|
||||
|
||||
class Bar
|
||||
{
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static bool $deprecatedPropery = false;
|
||||
}
|
||||
|
||||
Bar::$deprecatedPropery;
|
||||
',
|
||||
'error_message' => 'DeprecatedProperty',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user