From a2a507166d1d6d3b795b18ed299994b440de9da6 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 6 Mar 2020 09:42:23 -0500 Subject: [PATCH] Fix #2923 - remove hack to fix a template issue --- .../Expression/Call/StaticCallAnalyzer.php | 4 -- tests/PropertyTypeTest.php | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index 82bf8b9723f..1f4065bba80 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -639,10 +639,6 @@ function (PhpParser\Node\Arg $arg) { $context->include_location = $old_context_include_location; $context->self = $old_self; - - if (isset($context->vars_in_scope['$this'])) { - $context->vars_in_scope['$this'] = Type::parseString($old_self); - } } } diff --git a/tests/PropertyTypeTest.php b/tests/PropertyTypeTest.php index 9fad676d60c..b2194709eb8 100644 --- a/tests/PropertyTypeTest.php +++ b/tests/PropertyTypeTest.php @@ -1866,6 +1866,50 @@ public function foo() { } }', ], + 'someConditionalCallToParentConstructor' => [ + 'val = "hello"; + if (true) { + parent::__construct(); + } + } + } + + class ChildClass extends ParentClassDefinesVar { + public function __construct() { + parent::__construct(); + } + }' + ], + 'noConditionalCallToParentConstructor' => [ + 'val = "hello"; + parent::__construct(); + } + } + + class ChildClass extends ParentClassDefinesVar { + public function __construct() { + parent::__construct(); + } + }' + ], ]; }