From a2f52fd329330dc549092d0d3cf8bf6f1cec1810 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 3 Jul 2024 15:22:41 +0000 Subject: [PATCH] [ci-review] Rector Rectify --- src/DependencyInjection/LazyContainerFactory.php | 10 ++++++---- .../NameImportingPhpDocNodeVisitor.php | 10 +++++----- .../PhpDocParser/IntersectionPhpDocTypeMapper.php | 4 ++-- .../PhpDocParser/NullablePhpDocTypeMapper.php | 4 ++-- .../PhpDocParser/UnionPhpDocTypeMapper.php | 8 ++++---- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 0650b8049ab..3248680272d 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -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; @@ -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, @@ -300,7 +302,7 @@ final class LazyContainerFactory StringTypeMapper::class, ThisTypeMapper::class, TypeWithClassNameTypeMapper::class, - \Rector\PHPStanStaticTypeMapper\TypeMapper\UnionTypeMapper::class, + UnionTypeMapper::class, VoidTypeMapper::class, ]; @@ -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); diff --git a/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php b/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php index 068fcee3208..d6b6398c9ee 100644 --- a/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php +++ b/src/NodeTypeResolver/PhpDocNodeVisitor/NameImportingPhpDocNodeVisitor.php @@ -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'); @@ -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()); @@ -202,7 +202,7 @@ private function processDoctrineAnnotationTagValueNode( } $identifierTypeNode = $doctrineAnnotationTagValueNode->identifierTypeNode; - $staticType = $this->identifierTypeMapper->mapIdentifierTypeNode( + $staticType = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode( $identifierTypeNode, $currentPhpParserNode ); @@ -255,7 +255,7 @@ private function enterSpacelessPhpDocTagNode( throw new ShouldNotHappenException(); } - $staticType = $this->identifierTypeMapper->mapIdentifierTypeNode( + $staticType = $this->identifierPhpDocTypeMapper->mapIdentifierTypeNode( new IdentifierTypeNode($attributeClass), $currentPhpParserNode ); diff --git a/src/StaticTypeMapper/PhpDocParser/IntersectionPhpDocTypeMapper.php b/src/StaticTypeMapper/PhpDocParser/IntersectionPhpDocTypeMapper.php index 80a2e79c080..fdf46a25596 100644 --- a/src/StaticTypeMapper/PhpDocParser/IntersectionPhpDocTypeMapper.php +++ b/src/StaticTypeMapper/PhpDocParser/IntersectionPhpDocTypeMapper.php @@ -20,7 +20,7 @@ final readonly class IntersectionPhpDocTypeMapper implements PhpDocTypeMapperInterface { public function __construct( - private IdentifierPhpDocTypeMapper $identifierTypeMapper + private IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper ) { } @@ -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 ); diff --git a/src/StaticTypeMapper/PhpDocParser/NullablePhpDocTypeMapper.php b/src/StaticTypeMapper/PhpDocParser/NullablePhpDocTypeMapper.php index 207c12013ae..a8ea9c88835 100644 --- a/src/StaticTypeMapper/PhpDocParser/NullablePhpDocTypeMapper.php +++ b/src/StaticTypeMapper/PhpDocParser/NullablePhpDocTypeMapper.php @@ -21,7 +21,7 @@ final readonly class NullablePhpDocTypeMapper implements PhpDocTypeMapperInterface { public function __construct( - private IdentifierPhpDocTypeMapper $identifierTypeMapper, + private IdentifierPhpDocTypeMapper $identifierPhpDocTypeMapper, private TypeNodeResolver $typeNodeResolver ) { } @@ -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()]); diff --git a/src/StaticTypeMapper/PhpDocParser/UnionPhpDocTypeMapper.php b/src/StaticTypeMapper/PhpDocParser/UnionPhpDocTypeMapper.php index cc92b6eb543..a47111ddb5f 100644 --- a/src/StaticTypeMapper/PhpDocParser/UnionPhpDocTypeMapper.php +++ b/src/StaticTypeMapper/PhpDocParser/UnionPhpDocTypeMapper.php @@ -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 ) { } @@ -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; }