mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Add new suppressable error for missing closure return types
This commit is contained in:
parent
5315fd15ad
commit
2e2f2f4ffb
@ -102,6 +102,7 @@
|
||||
<xs:element name="InvalidToString" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MethodSignatureMismatch" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MisplacedRequiredParam" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingClosureReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingPropertyDeclaration" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingPropertyType" type="IssueHandlerType" minOccurs="0" />
|
||||
<xs:element name="MissingReturnType" type="IssueHandlerType" minOccurs="0" />
|
||||
|
@ -20,6 +20,7 @@ use Psalm\Issue\InvalidReturnType;
|
||||
use Psalm\Issue\InvalidToString;
|
||||
use Psalm\Issue\MethodSignatureMismatch;
|
||||
use Psalm\Issue\MisplacedRequiredParam;
|
||||
use Psalm\Issue\MissingClosureReturnType;
|
||||
use Psalm\Issue\MissingReturnType;
|
||||
use Psalm\Issue\MixedInferredReturnType;
|
||||
use Psalm\Issue\OverriddenMethodAccess;
|
||||
@ -785,6 +786,20 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
|
||||
}
|
||||
|
||||
if (!$return_type && !$update_docblock && !$is_to_string) {
|
||||
if ($this->function instanceof Closure) {
|
||||
if (IssueBuffer::accepts(
|
||||
new MissingClosureReturnType(
|
||||
'Closure does not have a return type',
|
||||
new CodeLocation($this, $this->function, true)
|
||||
),
|
||||
$this->suppressed_issues
|
||||
)) {
|
||||
// fall through
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (IssueBuffer::accepts(
|
||||
new MissingReturnType(
|
||||
'Method ' . $cased_method_id . ' does not have a return type',
|
||||
|
6
src/Psalm/Issue/MissingClosureReturnType.php
Normal file
6
src/Psalm/Issue/MissingClosureReturnType.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace Psalm\Issue;
|
||||
|
||||
class MissingClosureReturnType extends CodeError
|
||||
{
|
||||
}
|
@ -126,7 +126,7 @@ class ClosureTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$bam = array_map(
|
||||
/**
|
||||
* @psalm-suppress MissingReturnType
|
||||
* @psalm-suppress MissingClosureReturnType
|
||||
*/
|
||||
function(string $a) {
|
||||
return $a . "blah";
|
||||
|
Loading…
Reference in New Issue
Block a user