1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #1636 - don’t allow invalid phpdoc to be outputted

This commit is contained in:
Brown 2019-05-14 17:41:22 -04:00
parent e7f4a52d2b
commit 10272c2da1
3 changed files with 21 additions and 2 deletions

View File

@ -243,7 +243,7 @@ class FunctionDocblockManipulator
*/
public function setReturnType($php_type, $new_type, $phpdoc_type, $is_php_compatible, $description)
{
$new_type = str_replace(['<mixed, mixed>', '<array-key, mixed>', '<empty, empty>'], '', $new_type);
$new_type = str_replace(['<mixed, mixed>', '<array-key, mixed>'], '', $new_type);
$this->new_php_return_type = $php_type;
$this->new_phpdoc_return_type = $phpdoc_type;

View File

@ -73,7 +73,7 @@ trait GenericTrait
$value_type = $this->type_params[1];
if ($value_type->isMixed()) {
if ($value_type->isMixed() || $value_type->isEmpty()) {
return $base_value;
}

View File

@ -1208,6 +1208,25 @@ class ReturnTypeManipulationTest extends FileManipulationTest
false,
false,
],
'noEmptyArrayAnnotation' => [
'<?php
function foo() {
return [];
}',
'<?php
/**
* @return array
*
* @psalm-return array<empty, empty>
*/
function foo(): array {
return [];
}',
'7.3',
['MissingReturnType'],
false,
],
];
}
}