1
0
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:
Matthew Brown 2018-04-11 20:27:25 -04:00
parent e58274acaa
commit 1d6e75b06e
2 changed files with 19 additions and 10 deletions

View File

@ -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;
}

View File

@ -477,6 +477,14 @@ class CallableTest extends TestCase
);
}',
],
'allowVoidCallable' => [
'<?php
/**
* @param callable():void $p
*/
function doSomething($p): void {}
doSomething(function(): bool { return false; });',
],
];
}