diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php index 8f8d6d425..b1fb8079a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php @@ -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; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php index 38d335bd3..6e695c771 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php @@ -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]; diff --git a/tests/DeprecatedAnnotationTest.php b/tests/DeprecatedAnnotationTest.php index b7845eb0b..c703542b8 100644 --- a/tests/DeprecatedAnnotationTest.php +++ b/tests/DeprecatedAnnotationTest.php @@ -232,6 +232,21 @@ class DeprecatedAnnotationTest extends TestCase function foo(DeprecatedClass $deprecatedClass): void {}', 'error_message' => 'DeprecatedClass', ], + 'deprecatedStaticPropertyFetch' => [ + ' 'DeprecatedProperty', + ], ]; } }