Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jul 3, 2024
1 parent aeed5c4 commit a2f52fd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
10 changes: 6 additions & 4 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Rector\DependencyInjection;

use Rector\PHPStanStaticTypeMapper\TypeMapper\IntersectionTypeMapper;
use Rector\PHPStanStaticTypeMapper\TypeMapper\UnionTypeMapper;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\Rules\English\InflectorFactory;
use Illuminate\Container\Container;
Expand Down Expand Up @@ -283,7 +285,7 @@ final class LazyContainerFactory
HasOffsetValueTypeTypeMapper::class,
HasPropertyTypeMapper::class,
IntegerTypeMapper::class,
\Rector\PHPStanStaticTypeMapper\TypeMapper\IntersectionTypeMapper::class,
IntersectionTypeMapper::class,
IterableTypeMapper::class,
MixedTypeMapper::class,
NeverTypeMapper::class,
Expand All @@ -300,7 +302,7 @@ final class LazyContainerFactory
StringTypeMapper::class,
ThisTypeMapper::class,
TypeWithClassNameTypeMapper::class,
\Rector\PHPStanStaticTypeMapper\TypeMapper\UnionTypeMapper::class,
UnionTypeMapper::class,
VoidTypeMapper::class,
];

Expand Down Expand Up @@ -499,9 +501,9 @@ static function (ConditionalTypeMapper $conditionalTypeMapper, Container $contai
);

$rectorConfig->afterResolving(
\Rector\PHPStanStaticTypeMapper\TypeMapper\UnionTypeMapper::class,
UnionTypeMapper::class,
static function (
\Rector\PHPStanStaticTypeMapper\TypeMapper\UnionTypeMapper $unionTypeMapper,
UnionTypeMapper $unionTypeMapper,
Container $container
): void {
$phpStanStaticTypeMapper = $container->make(PHPStanStaticTypeMapper::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public function __construct(
private readonly UseNodesToAddCollector $useNodesToAddCollector,
private readonly CurrentFileProvider $currentFileProvider,
private readonly ReflectionProvider $reflectionProvider,
private readonly IdentifierPhpDocTypeMapper $identifierTypeMapper,
private readonly IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper,
) {
}

public function beforeTraverse(Node $node): void
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node): void
{
if (! $this->currentPhpParserNode instanceof PhpParserNode) {
throw new ShouldNotHappenException('Set "$currentPhpParserNode" first');
Expand All @@ -67,7 +67,7 @@ public function enterNode(Node $node): ?Node
throw new ShouldNotHappenException();
}

$staticType = $this->identifierTypeMapper->mapIdentifierTypeNode($node, $this->currentPhpParserNode);
$staticType = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode($node, $this->currentPhpParserNode);

if ($staticType instanceof ShortenedObjectType) {
$staticType = new FullyQualifiedObjectType($staticType->getFullyQualifiedName());
Expand Down Expand Up @@ -202,7 +202,7 @@ private function processDoctrineAnnotationTagValueNode(
}

$identifierTypeNode = $doctrineAnnotationTagValueNode->identifierTypeNode;
$staticType = $this->identifierTypeMapper->mapIdentifierTypeNode(
$staticType = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode(
$identifierTypeNode,
$currentPhpParserNode
);
Expand Down Expand Up @@ -255,7 +255,7 @@ private function enterSpacelessPhpDocTagNode(
throw new ShouldNotHappenException();
}

$staticType = $this->identifierTypeMapper->mapIdentifierTypeNode(
$staticType = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode(
new IdentifierTypeNode($attributeClass),
$currentPhpParserNode
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final readonly class IntersectionPhpDocTypeMapper implements PhpDocTypeMapperInterface
{
public function __construct(
private IdentifierPhpDocTypeMapper $identifierTypeMapper
private IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper
) {
}

Expand All @@ -40,7 +40,7 @@ public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $name
return new MixedType();
}

$intersectionedTypes[] = $this->identifierTypeMapper->mapIdentifierTypeNode(
$intersectionedTypes[] = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode(
$intersectionedTypeNode,
$node
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
final readonly class NullablePhpDocTypeMapper implements PhpDocTypeMapperInterface
{
public function __construct(
private IdentifierPhpDocTypeMapper $identifierTypeMapper,
private IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper,
private TypeNodeResolver $typeNodeResolver
) {
}
Expand All @@ -37,7 +37,7 @@ public function getNodeType(): string
public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope): Type
{
if ($typeNode->type instanceof IdentifierTypeNode) {
$type = $this->identifierTypeMapper->mapToPHPStanType($typeNode->type, $node, $nameScope);
$type = $this->identifierPhpDocTypeMapper->mapToPHPStanType($typeNode->type, $node, $nameScope);

if ($type instanceof UnionType) {
return new UnionType([new NullType(), ...$type->getTypes()]);
Expand Down
8 changes: 4 additions & 4 deletions src/StaticTypeMapper/PhpDocParser/UnionPhpDocTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
{
public function __construct(
private TypeFactory $typeFactory,
private IdentifierPhpDocTypeMapper $identifierTypeMapper,
private IntersectionPhpDocTypeMapper $intersectionTypeMapper,
private IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper,
private IntersectionPhpDocTypeMapper $intersectionPhpDocTypeMapper,
private TypeNodeResolver $typeNodeResolver
) {
}
Expand All @@ -41,12 +41,12 @@ public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $name
$unionedTypes = [];
foreach ($typeNode->types as $unionedTypeNode) {
if ($unionedTypeNode instanceof IdentifierTypeNode) {
$unionedTypes[] = $this->identifierTypeMapper->mapToPHPStanType($unionedTypeNode, $node, $nameScope);
$unionedTypes[] = $this->identifierPhpDocTypeMapper->mapToPHPStanType($unionedTypeNode, $node, $nameScope);
continue;
}

if ($unionedTypeNode instanceof IntersectionTypeNode) {
$unionedTypes[] = $this->intersectionTypeMapper->mapToPHPStanType($unionedTypeNode, $node, $nameScope);
$unionedTypes[] = $this->intersectionPhpDocTypeMapper->mapToPHPStanType($unionedTypeNode, $node, $nameScope);
continue;
}

Expand Down

0 comments on commit a2f52fd

Please sign in to comment.