Skip to content

[DI] Convert two more order-independent collections to autodiscover - #8371

Merged
TomasVotruba merged 1 commit into
mainfrom
autodiscover-more-collections
Aug 25, 2026
Merged

[DI] Convert two more order-independent collections to autodiscover#8371
TomasVotruba merged 1 commit into
mainfrom
autodiscover-more-collections

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Follow-up to #8370. Converts two more collections from registerTagged() to autodiscover().

Both were previously held back as "order-sensitive", but verification shows their consumers match mutually exclusively — no input can match two entries — so filesystem registration order is irrelevant:

CollectionConsumerWhy order-independent
NodeNameResolverInterfaceis_a($node, $resolver->getNode())10 distinct PhpParser nodes, no inheritance overlap among the targets
PhpDocTypeMapperInterfaceis_a($typeNode, $mapper->getNodeType())4 siblings that all implements TypeNode, none extends another

The remaining registerTagged() collections stay put because their matches do overlap and curated order is significant:

  • TypeMapperInterfaceConstantArrayType extends ArrayType
  • PhpParserNodeMapperInterfaceFullyQualified extends Name
  • AnnotationToAttributeMapperInterfaceString (is_string) is a superset of ClassConstFetch (is_string && '::')
- $this->registerTagged($rectorConfig, self::PHPDOC_TYPE_MAPPER_CLASSES, PhpDocTypeMapperInterface::class);- $this->registerTagged($rectorConfig, self::NODE_NAME_RESOLVER_CLASSES, NodeNameResolverInterface::class);+ $rectorConfig->autodiscover(__DIR__ . '/../StaticTypeMapper/PhpDocParser');+ $rectorConfig->autodiscover(__DIR__ . '/../NodeNameResolver/NodeNameResolver');

Both interfaces added to the class-leak skip list (their implementors are now discovered, not referenced). Verified each collection still resolves the same service count after boot (10 / 4), with no regression on the untouched collections (29 / 12).

@TomasVotruba
TomasVotruba merged commit 0fbd678 into mainAug 25, 2026
43 of 44 checks passed
@TomasVotruba
TomasVotruba deleted the autodiscover-more-collections branch August 25, 2026 07:07
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@TomasVotruba