Skip to content

Commit

Permalink
[PHPStanStaticTypeMapper] Reduce autowire() parameter on ArrayTypeMap…
Browse files Browse the repository at this point in the history
…per (#4696)

* [PHPStanStaticTypeMapper] Reduce autowire() parameter on ArrayTypeMapper

* [PHPStanStaticTypeMapper] Reduce autowire() parameter on ArrayTypeMapper

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Aug 7, 2023
1 parent a459f5a commit bb284f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
29 changes: 10 additions & 19 deletions packages/PHPStanStaticTypeMapper/TypeMapper/ArrayTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,22 @@ final class ArrayTypeMapper implements TypeMapperInterface
*/
public const HAS_GENERIC_TYPE_PARENT = 'has_generic_type_parent';

private PHPStanStaticTypeMapper $phpStanStaticTypeMapper;

private UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower;

private ReflectionProvider $reflectionProvider;

private GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer;
public function __construct(
private readonly UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower,
private readonly ReflectionProvider $reflectionProvider,
private readonly GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer,
private readonly DetailedTypeAnalyzer $detailedTypeAnalyzer
) {
}

private DetailedTypeAnalyzer $detailedTypeAnalyzer;
private PHPStanStaticTypeMapper $phpStanStaticTypeMapper;

// To avoid circular dependency

#[Required]
public function autowire(
PHPStanStaticTypeMapper $phpStanStaticTypeMapper,
UnionTypeCommonTypeNarrower $unionTypeCommonTypeNarrower,
ReflectionProvider $reflectionProvider,
GenericClassStringTypeNormalizer $genericClassStringTypeNormalizer,
DetailedTypeAnalyzer $detailedTypeAnalyzer,
): void {
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper): void
{
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
$this->unionTypeCommonTypeNarrower = $unionTypeCommonTypeNarrower;
$this->reflectionProvider = $reflectionProvider;
$this->genericClassStringTypeNormalizer = $genericClassStringTypeNormalizer;
$this->detailedTypeAnalyzer = $detailedTypeAnalyzer;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
use Rector\PhpAttribute\Contract\AnnotationToAttributeMapperInterface;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower;
use Rector\PHPStanStaticTypeMapper\TypeMapper\AccessoryLiteralStringTypeMapper;
use Rector\PHPStanStaticTypeMapper\TypeMapper\AccessoryNonEmptyStringTypeMapper;
use Rector\PHPStanStaticTypeMapper\TypeMapper\AccessoryNonFalsyStringTypeMapper;
Expand Down Expand Up @@ -135,8 +134,6 @@
use Rector\StaticTypeMapper\PhpParser\StringNodeMapper;
use Rector\StaticTypeMapper\PhpParser\UnionTypeNodeMapper;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\TypeDeclaration\NodeTypeAnalyzer\DetailedTypeAnalyzer;
use Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer;
use Symfony\Component\Console\Application;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -400,11 +397,7 @@ static function (NameScopeFactory $nameScopeFactory, Container $container): void
ArrayTypeMapper::class,
static function (ArrayTypeMapper $arrayTypeMapper, Container $container): void {
$arrayTypeMapper->autowire(
$container->make(PHPStanStaticTypeMapper::class),
$container->make(UnionTypeCommonTypeNarrower::class),
$container->make(ReflectionProvider::class),
$container->make(GenericClassStringTypeNormalizer::class),
$container->make(DetailedTypeAnalyzer::class),
$container->make(PHPStanStaticTypeMapper::class)
);
}
);
Expand Down

0 comments on commit bb284f6

Please sign in to comment.