1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #1108 - add support for referencedFunction to UndefinedFunction

This commit is contained in:
Matthew Brown 2018-11-29 23:19:22 -05:00
parent f84224b7e9
commit 21f29e7385
4 changed files with 32 additions and 4 deletions

View File

@ -324,8 +324,14 @@ class FileFilter
*/ */
public function allowsMethod($method_id) public function allowsMethod($method_id)
{ {
$method_stub = '*::' . explode('::', $method_id)[1]; if (preg_match('/^[^:]+::[^:]+$/', $method_id)) {
return in_array($method_id, $this->method_ids) || in_array($method_stub, $this->method_ids); $method_stub = '*::' . explode('::', $method_id)[1];
if (in_array($method_stub, $this->method_ids)) {
return true;
}
}
return in_array($method_id, $this->method_ids);
} }
/** /**

View File

@ -2118,7 +2118,8 @@ class CallAnalyzer
if (IssueBuffer::accepts( if (IssueBuffer::accepts(
new UndefinedFunction( new UndefinedFunction(
'Function ' . $cased_function_id . ' does not exist', 'Function ' . $cased_function_id . ' does not exist',
$code_location $code_location,
$function_id
), ),
$statements_analyzer->getSuppressedIssues() $statements_analyzer->getSuppressedIssues()
)) { )) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Psalm\Issue; namespace Psalm\Issue;
class UndefinedFunction extends CodeIssue class UndefinedFunction extends MethodIssue
{ {
} }

View File

@ -319,6 +319,11 @@ class ConfigTest extends TestCase
<referencedMethod name="*::find2" /> <referencedMethod name="*::find2" />
</errorLevel> </errorLevel>
</UndefinedMethod> </UndefinedMethod>
<UndefinedFunction>
<errorLevel type="suppress">
<referencedFunction name="fooBar" />
</errorLevel>
</UndefinedFunction>
<UndefinedPropertyFetch> <UndefinedPropertyFetch>
<errorLevel type="suppress"> <errorLevel type="suppress">
<referencedProperty name="Psalm\Bodger::$find3" /> <referencedProperty name="Psalm\Bodger::$find3" />
@ -402,6 +407,22 @@ class ConfigTest extends TestCase
'Psalm\Bodger::$find4' 'Psalm\Bodger::$find4'
) )
); );
$this->assertSame(
'suppress',
$config->getReportingLevelForMethod(
'UndefinedFunction',
'fooBar'
)
);
$this->assertSame(
'suppress',
$config->getReportingLevelForMethod(
'UndefinedFunction',
'foobar'
)
);
} }
/** /**