mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1108 - add support for referencedFunction to UndefinedFunction
This commit is contained in:
parent
f84224b7e9
commit
21f29e7385
@ -324,8 +324,14 @@ class FileFilter
|
||||
*/
|
||||
public function allowsMethod($method_id)
|
||||
{
|
||||
$method_stub = '*::' . explode('::', $method_id)[1];
|
||||
return in_array($method_id, $this->method_ids) || in_array($method_stub, $this->method_ids);
|
||||
if (preg_match('/^[^:]+::[^:]+$/', $method_id)) {
|
||||
$method_stub = '*::' . explode('::', $method_id)[1];
|
||||
|
||||
if (in_array($method_stub, $this->method_ids)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return in_array($method_id, $this->method_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2118,7 +2118,8 @@ class CallAnalyzer
|
||||
if (IssueBuffer::accepts(
|
||||
new UndefinedFunction(
|
||||
'Function ' . $cased_function_id . ' does not exist',
|
||||
$code_location
|
||||
$code_location,
|
||||
$function_id
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues()
|
||||
)) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class UndefinedFunction extends CodeIssue
|
||||
class UndefinedFunction extends MethodIssue
|
||||
{
|
||||
}
|
||||
|
@ -319,6 +319,11 @@ class ConfigTest extends TestCase
|
||||
<referencedMethod name="*::find2" />
|
||||
</errorLevel>
|
||||
</UndefinedMethod>
|
||||
<UndefinedFunction>
|
||||
<errorLevel type="suppress">
|
||||
<referencedFunction name="fooBar" />
|
||||
</errorLevel>
|
||||
</UndefinedFunction>
|
||||
<UndefinedPropertyFetch>
|
||||
<errorLevel type="suppress">
|
||||
<referencedProperty name="Psalm\Bodger::$find3" />
|
||||
@ -402,6 +407,22 @@ class ConfigTest extends TestCase
|
||||
'Psalm\Bodger::$find4'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'suppress',
|
||||
$config->getReportingLevelForMethod(
|
||||
'UndefinedFunction',
|
||||
'fooBar'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'suppress',
|
||||
$config->getReportingLevelForMethod(
|
||||
'UndefinedFunction',
|
||||
'foobar'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user