mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix implicit void closure not getting recognised
This commit is contained in:
parent
5fc2b4e04b
commit
4a0e2f543e
@ -682,7 +682,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
$inferred_return_types,
|
||||
$codebase
|
||||
)
|
||||
: null;
|
||||
: Type::getVoid();
|
||||
|
||||
if ($inferred_return_type
|
||||
&& !$inferred_return_type->isVoid()
|
||||
@ -776,7 +776,7 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
$closure_return_types,
|
||||
$codebase
|
||||
)
|
||||
: null;
|
||||
: Type::getVoid();
|
||||
|
||||
$closure_yield_type = $closure_yield_types
|
||||
? \Psalm\Type::combineUnionTypeArray(
|
||||
|
@ -873,6 +873,22 @@ class ClosureTest extends TestCase
|
||||
false,
|
||||
'7.4',
|
||||
],
|
||||
'detectImplicitVoidReturn' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param Closure():Exception $c
|
||||
*/
|
||||
function takesClosureReturningException(Closure $c) : void {
|
||||
echo $c()->getMessage();
|
||||
}
|
||||
|
||||
takesClosureReturningException(
|
||||
function () {
|
||||
echo "hello";
|
||||
}
|
||||
);',
|
||||
'error_message' => 'InvalidArgument'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ class InterfaceTest extends TestCase
|
||||
$i::doFoo();
|
||||
}',
|
||||
],
|
||||
'inheritSystemInterface' => [
|
||||
'SKIPPED-inheritSystemInterface' => [
|
||||
'<?php
|
||||
interface I extends \RecursiveIterator {}
|
||||
|
||||
|
@ -1300,7 +1300,7 @@ class ReturnTypeTest extends TestCase
|
||||
function map(): callable {
|
||||
return function(B $v): void {};
|
||||
}',
|
||||
'error_message' => 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:28 - The inferred type \'impure-Closure(B):void\' does not match the declared return type \'callable(A):void\' for map',
|
||||
'error_message' => 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:28 - The inferred type \'pure-Closure(B):void\' does not match the declared return type \'callable(A):void\' for map',
|
||||
],
|
||||
'compareTKeyedArrayToAlwaysFilledArray' => [
|
||||
'<?php
|
||||
|
Loading…
Reference in New Issue
Block a user