[PHP 8.0] Skip void type in union (#4835)

This commit is contained in:
Tomas Votruba 2020-12-09 19:38:45 +01:00 committed by GitHub
parent eac130e705
commit e157da77f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -230,6 +230,11 @@ final class UnionTypeMapper implements TypeMapperInterface
$phpParserUnionedTypes = [];
foreach ($unionType->getTypes() as $unionedType) {
// void type is not allowed in union
if ($unionedType instanceof VoidType) {
return null;
}
/** @var Identifier|Name|null $phpParserNode */
$phpParserNode = $this->phpStanStaticTypeMapper->mapToPhpParserNode($unionedType);
if ($phpParserNode === null) {

View File

@ -0,0 +1,13 @@
<?php
namespace Rector\Php80\Tests\Rector\FunctionLike\UnionTypesRector\Fixture;
class SkipVoid
{
/**
* @return int|void
*/
public function go()
{
}
}