Skip to content

Commit

Permalink
Inaccurate error with different types in PHPDoc and typehint
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Jul 26, 2021
1 parent ffbdaa8 commit 72d6024
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Psalm\Exception\TypeParseTreeException;
use Psalm\Internal\Scanner\FileScanner;
use Psalm\Internal\Scanner\FunctionDocblockComment;
use Psalm\Internal\Type\Comparator\UnionTypeComparator;
use Psalm\Internal\Type\TypeAlias;
use Psalm\Internal\Type\TypeParser;
use Psalm\Internal\Type\TypeTokenizer;
Expand Down Expand Up @@ -908,6 +909,12 @@ private static function handleReturn(
&& !$storage->return_type->isNullable()
&& !$storage->return_type->hasTemplate()
&& !$storage->return_type->hasConditional()
//don't add null to docblock type if it's not contained in signature type
&& UnionTypeComparator::isContainedBy(
$codebase,
$storage->return_type,
$storage->signature_return_type
)
) {
$storage->return_type->addType(new Type\Atomic\TNull());
}
Expand Down

0 comments on commit 72d6024

Please sign in to comment.