mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Fix #662 - allow callable void return types to be widened
This commit is contained in:
parent
e58274acaa
commit
1d6e75b06e
@ -746,16 +746,17 @@ class TypeChecker
|
||||
|
||||
$all_types_contain = false;
|
||||
} else {
|
||||
if (!self::isContainedBy(
|
||||
$codebase,
|
||||
$input_type_part->return_type,
|
||||
$container_type_part->return_type,
|
||||
false,
|
||||
false,
|
||||
$has_scalar_match,
|
||||
$type_coerced,
|
||||
$type_coerced_from_mixed
|
||||
)
|
||||
if (!$container_type_part->return_type->isVoid()
|
||||
&& !self::isContainedBy(
|
||||
$codebase,
|
||||
$input_type_part->return_type,
|
||||
$container_type_part->return_type,
|
||||
false,
|
||||
false,
|
||||
$has_scalar_match,
|
||||
$type_coerced,
|
||||
$type_coerced_from_mixed
|
||||
)
|
||||
) {
|
||||
$all_types_contain = false;
|
||||
}
|
||||
|
@ -477,6 +477,14 @@ class CallableTest extends TestCase
|
||||
);
|
||||
}',
|
||||
],
|
||||
'allowVoidCallable' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param callable():void $p
|
||||
*/
|
||||
function doSomething($p): void {}
|
||||
doSomething(function(): bool { return false; });',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user