diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php index 5166cc16cb4..52265878bcf 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; @@ -483,10 +485,13 @@ public static function analyze( ); } + /** + * @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 b1226382e95..ea4903795de 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php @@ -265,6 +265,13 @@ public static function analyze( 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 b7845eb0b88..c703542b834 100644 --- a/tests/DeprecatedAnnotationTest.php +++ b/tests/DeprecatedAnnotationTest.php @@ -232,6 +232,21 @@ class DeprecatedClass{} function foo(DeprecatedClass $deprecatedClass): void {}', 'error_message' => 'DeprecatedClass', ], + 'deprecatedStaticPropertyFetch' => [ + ' 'DeprecatedProperty', + ], ]; } }