mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Restore support for namespaced functions in referencedFunction config
This commit is contained in:
parent
8362cc6900
commit
8fbe14a34b
@ -336,7 +336,7 @@ class FileFilter
|
||||
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(
|
||||
|
@ -18,6 +18,7 @@ use Psalm\Internal\Provider\Providers;
|
||||
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 @@ class ConfigTest extends TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function testReferencedFunctionAllowsNamespacedFunctions(): void
|
||||
{
|
||||
$config_xml = Config::loadFromXML(
|
||||
(string) getcwd(),
|
||||
<<<XML
|
||||
<?xml version="1.0"?>
|
||||
<psalm>
|
||||
<issueHandlers>
|
||||
<UndefinedFunction>
|
||||
<errorLevel type="suppress">
|
||||
<referencedFunction name="Foo\Bar\baz" />
|
||||
</errorLevel>
|
||||
</UndefinedFunction>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
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',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user