From 96d05ab06b657fe985be6f795be67438328ba678 Mon Sep 17 00:00:00 2001 From: Brown Date: Tue, 23 Jun 2020 16:53:11 -0400 Subject: [PATCH] Fix #3654 - use correct function id for namespaced functions --- .../Analyzer/FunctionLikeAnalyzer.php | 7 +++--- tests/TaintTest.php | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 9bf173d2930..dd661486270 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -324,11 +324,10 @@ public function analyze( $context->calling_method_id = strtolower((string) $method_id); } } elseif ($this->function instanceof Function_) { - $cased_method_id = $this->function->name->name; + $function_name = $this->function->name->name; $namespace_prefix = $this->getNamespace(); - $context->calling_function_id = strtolower( - ($namespace_prefix !== null ? $namespace_prefix . '\\' : '') . $cased_method_id - ); + $cased_method_id = ($namespace_prefix !== null ? $namespace_prefix . '\\' : '') . $function_name; + $context->calling_function_id = strtolower($cased_method_id); } else { // Closure if ($storage->return_type) { $closure_return_type = \Psalm\Internal\Type\TypeExpander::expandUnion( diff --git a/tests/TaintTest.php b/tests/TaintTest.php index 4440c35a90d..d4b21e34a74 100644 --- a/tests/TaintTest.php +++ b/tests/TaintTest.php @@ -1856,4 +1856,26 @@ public function testEncapsulatedString() : void $this->analyzeFile('somefile.php', new Context()); } + + public function testNamespacedFunction() : void + { + $this->expectException(\Psalm\Exception\CodeException::class); + $this->expectExceptionMessage('TaintedInput'); + + $this->project_analyzer->trackTaintedInputs(); + + $this->addFile( + 'somefile.php', + 'analyzeFile('somefile.php', new Context()); + } }