diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 34944da0a..ecc6b8f67 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -288,9 +288,25 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna $statements_analyzer->node_data->setType($stmt, $new_type); } + self::checkFunctionArguments( + $statements_analyzer, + $stmt->args, + null, + null, + $context + ); + return null; } } else { + self::checkFunctionArguments( + $statements_analyzer, + $stmt->args, + null, + null, + $context + ); + return null; } } @@ -311,6 +327,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna if ($context->check_classes) { if ($context->isPhantomClass($fq_class_name)) { + self::checkFunctionArguments( + $statements_analyzer, + $stmt->args, + null, + null, + $context + ); + return null; } @@ -323,6 +347,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna $statements_analyzer->getSuppressedIssues(), false ) === false) { + self::checkFunctionArguments( + $statements_analyzer, + $stmt->args, + null, + null, + $context + ); + return; } @@ -543,6 +575,14 @@ class NewAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\CallAna $stmt_type->reference_free = true; } } + } else { + self::checkFunctionArguments( + $statements_analyzer, + $stmt->args, + null, + null, + $context + ); } } diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index d0514bad7..acccab46b 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -1100,7 +1100,13 @@ class MethodCallTest extends TestCase foo(new AChild());', 'error_message' => 'PossiblyNullArgument' - ] + ], + 'checkVariableInUnknownClassConstructor' => [ + ' 'PossiblyUndefinedVariable', + ], ]; } }