diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php index 8ca44094724..4ef5f993c4c 100644 --- a/src/Psalm/Config/FileFilter.php +++ b/src/Psalm/Config/FileFilter.php @@ -336,7 +336,7 @@ public static function loadFromArray( foreach ($config['referencedFunction'] as $referenced_function) { $function_id = $referenced_function['name'] ?? ''; if (!is_string($function_id) - || (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $function_id) + || (!preg_match('/^[a-zA-Z_\x80-\xff](?:[\\\\]?[a-zA-Z0-9_\x80-\xff]+)*$/', $function_id) && !preg_match('/^[^:]+::[^:]+$/', $function_id) // methods are also allowed && !static::isRegularExpression($function_id))) { throw new ConfigException( diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index da14fa40fcf..c4b682967b3 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -18,6 +18,7 @@ use Psalm\Internal\RuntimeCaches; use Psalm\Internal\Scanner\FileScanner; use Psalm\Issue\TooManyArguments; +use Psalm\Issue\UndefinedFunction; use Psalm\Tests\Config\Plugin\FileTypeSelfRegisteringPlugin; use Psalm\Tests\Internal\Provider\FakeParserCacheProvider; use Psalm\Tests\TestCase; @@ -1856,4 +1857,34 @@ public function testReferencedFunctionAllowsMethods(): void ), ); } + + public function testReferencedFunctionAllowsNamespacedFunctions(): void + { + $config_xml = Config::loadFromXML( + (string) getcwd(), + << + + + + + + + + + + XML, + ); + + $this->assertSame( + Config::REPORT_SUPPRESS, + $config_xml->getReportingLevelForIssue( + new UndefinedFunction( + 'Function Foo\Bar\baz does not exist', + new Raw('aaa', 'aaa.php', 'aaa.php', 1, 2), + 'foo\bar\baz', + ), + ), + ); + } }