From 4046b449037ca24757e3f303a8e3f0a0478f5c4f Mon Sep 17 00:00:00 2001 From: Brown Date: Mon, 12 Aug 2019 14:29:14 -0400 Subject: [PATCH] fix #2010 - properties with defaults should work with static type --- .../Assignment/PropertyAssignmentAnalyzer.php | 2 +- tests/PropertyTypeTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/PropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/PropertyAssignmentAnalyzer.php index 8551f898b..decfd3244 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/PropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/PropertyAssignmentAnalyzer.php @@ -101,7 +101,7 @@ class PropertyAssignmentAnalyzer $codebase, $class_property_type, $context->self, - null, + $context->self, $class_storage->parent_class ); } diff --git a/tests/PropertyTypeTest.php b/tests/PropertyTypeTest.php index c942a2c1d..385ae60d3 100644 --- a/tests/PropertyTypeTest.php +++ b/tests/PropertyTypeTest.php @@ -1693,6 +1693,16 @@ class PropertyTypeTest extends TestCase echo (new B)->bar;' ], + 'staticPropertyDefaultWithStaticType' => [ + ' */ + private static $t1 = []; + + /** @var array */ + private $t2 = []; + }' + ] ]; }