Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from priyadi/fix-property-info
Browse files Browse the repository at this point in the history
Change PropertyInfoPass to use the same set of property extractors as the main package
  • Loading branch information
Korbeil authored Jan 3, 2024
2 parents 8093a57 + 6548fcc commit 29ce8e1
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/DependencyInjection/Compiler/PropertyInfoPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public function process(ContainerBuilder $container): void
return;
}

$propertyInfoDefinition = $container->findDefinition('property_info');

$container->setDefinition(
'automapper.property_info.reflection_extractor.inner',
new Definition(
Expand All @@ -47,11 +45,22 @@ public function process(ContainerBuilder $container): void
new Definition(
PropertyInfoExtractor::class,
[
$this->replaceReflectionExtractor($propertyInfoDefinition->getArgument(0)),
$this->replaceReflectionExtractor($propertyInfoDefinition->getArgument(1)),
$this->replaceReflectionExtractor($propertyInfoDefinition->getArgument(2)),
$this->replaceReflectionExtractor($propertyInfoDefinition->getArgument(3)),
$this->replaceReflectionExtractor($propertyInfoDefinition->getArgument(4)),
new IteratorArgument([
new Reference('automapper.property_info.reflection_extractor'),
]),
new IteratorArgument([
new Reference('property_info.phpstan_extractor'),
new Reference('automapper.property_info.reflection_extractor'),
]),
new IteratorArgument([
new Reference('automapper.property_info.reflection_extractor'),
]),
new IteratorArgument([
new Reference('automapper.property_info.reflection_extractor'),
]),
new IteratorArgument([
new Reference('automapper.property_info.reflection_extractor'),
]),
]
)
);
Expand All @@ -64,18 +73,4 @@ public function process(ContainerBuilder $container): void
])
)->setDecoratedService('automapper.property_info');
}

private function replaceReflectionExtractor(IteratorArgument $extractors): IteratorArgument
{
$newExtractors = [];

/** @var Reference $extractor */
foreach ($extractors->getValues() as $extractor) {
$newExtractors[] = (string) $extractor === 'property_info.reflection_extractor'
? new Reference('automapper.property_info.reflection_extractor')
: $extractor;
}

return new IteratorArgument($newExtractors);
}
}

0 comments on commit 29ce8e1

Please sign in to comment.