Skip to content

Commit

Permalink
Updated Rector to commit acb0b5d3ad760e7253fb6f49b4047ec6226384d4
Browse files Browse the repository at this point in the history
rectorphp/rector-src@acb0b5d [PHPStanStaticTypeMapper] Clean up UnionTypeMapper: remove unused TypeFactory usage (#5863)
  • Loading branch information
TomasVotruba committed May 8, 2024
1 parent 9da012c commit ed1310b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'bb90e0bbafee5e47720d9fda8f7e46fad5bd90a2';
public const PACKAGE_VERSION = 'acb0b5d3ad760e7253fb6f49b4047ec6226384d4';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-05-08 21:03:45';
public const RELEASE_DATE = '2024-05-09 06:49:57';
/**
* @var int
*/
Expand Down
21 changes: 3 additions & 18 deletions src/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use PHPStan\Type\VoidType;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\Php\PhpVersionProvider;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
Expand Down Expand Up @@ -56,21 +55,15 @@ final class UnionTypeMapper implements TypeMapperInterface
* @var \Rector\NodeNameResolver\NodeNameResolver
*/
private $nodeNameResolver;
/**
* @readonly
* @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory
*/
private $typeFactory;
/**
* @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper
*/
private $phpStanStaticTypeMapper;
public function __construct(PhpVersionProvider $phpVersionProvider, UnionTypeAnalyzer $unionTypeAnalyzer, NodeNameResolver $nodeNameResolver, TypeFactory $typeFactory)
public function __construct(PhpVersionProvider $phpVersionProvider, UnionTypeAnalyzer $unionTypeAnalyzer, NodeNameResolver $nodeNameResolver)
{
$this->phpVersionProvider = $phpVersionProvider;
$this->unionTypeAnalyzer = $unionTypeAnalyzer;
$this->nodeNameResolver = $nodeNameResolver;
$this->typeFactory = $typeFactory;
}
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void
{
Expand Down Expand Up @@ -246,7 +239,7 @@ private function matchTypeForUnionedTypes(UnionType $unionType, string $typeKind
return $phpParserUnionType;
}
if ($phpParserUnionType instanceof PhpParserUnionType) {
return $this->resolveUnionTypeNode($unionType, $phpParserUnionType, $typeKind);
return $this->resolveUnionTypeNode($phpParserUnionType);
}
return $phpParserUnionType;
}
Expand Down Expand Up @@ -358,22 +351,14 @@ private function correctObjectType(TypeWithClassName $typeWithClassName) : TypeW
}
return $typeWithClassName;
}
/**
* @param TypeKind::* $typeKind
* @return PhpParserUnionType|null|\PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\ComplexType
*/
private function resolveUnionTypeNode(UnionType $unionType, PhpParserUnionType $phpParserUnionType, string $typeKind)
private function resolveUnionTypeNode(PhpParserUnionType $phpParserUnionType) : ?PhpParserUnionType
{
if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_TYPES)) {
return null;
}
if ($this->hasObjectAndStaticType($phpParserUnionType)) {
return null;
}
$unionType = $this->typeFactory->createMixedPassedOrUnionType($unionType->getTypes());
if (!$unionType instanceof UnionType) {
return $this->phpStanStaticTypeMapper->mapToPhpParserNode($unionType, $typeKind);
}
return $phpParserUnionType;
}
}

0 comments on commit ed1310b

Please sign in to comment.