mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
commit
f62c76a334
@ -348,6 +348,13 @@ class FunctionCallReturnTypeFetcher
|
||||
return new Type\Union([new Type\Atomic\TIntRange($min, null)]);
|
||||
}
|
||||
|
||||
if ($atomic_types['array'] instanceof Type\Atomic\TArray
|
||||
&& $atomic_types['array']->type_params[0]->isEmpty()
|
||||
&& $atomic_types['array']->type_params[1]->isEmpty()
|
||||
) {
|
||||
return Type::getInt(false, 0);
|
||||
}
|
||||
|
||||
return new Type\Union([
|
||||
new Type\Atomic\TLiteralInt(0),
|
||||
new Type\Atomic\TPositiveInt
|
||||
|
@ -543,13 +543,13 @@ class FunctionLikeDocblockParser
|
||||
foreach ($return_specials as $offset => $return_block) {
|
||||
$return_lines = explode("\n", $return_block);
|
||||
|
||||
if (!trim($return_lines[0])) {
|
||||
if (trim($return_lines[0]) === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$return_block = trim($return_block);
|
||||
|
||||
if (!$return_block) {
|
||||
if ($return_block === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,7 @@ class FunctionLikeDocblockScanner
|
||||
}
|
||||
}
|
||||
|
||||
if ($docblock_info->return_type) {
|
||||
if ($docblock_info->return_type !== null) {
|
||||
self::handleReturn(
|
||||
$codebase,
|
||||
$docblock_info,
|
||||
|
@ -950,6 +950,15 @@ class ReturnTypeTest extends TestCase
|
||||
returnsNever();
|
||||
}'
|
||||
],
|
||||
'return0' => [
|
||||
'<?php
|
||||
/**
|
||||
* @return 0
|
||||
*/
|
||||
function takesAnInt() {
|
||||
return 0;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user