Skip to content

[DI] Autodiscover AnnotationToAttributeMapper via mutually exclusive candidates - #8375

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

[DI] Autodiscover AnnotationToAttributeMapper via mutually exclusive candidates#8375
TomasVotruba merged 1 commit into
mainfrom
annotationmapper-autodiscover

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Third of three parallel experiments removing order-sensitive registerTagged() collections in favor of autodiscover().

AnnotationToAttributeMapper matched by first isCandidate() in registration order. The one order-sensitive overlap: StringAnnotationToAttributeMapper::isCandidate() returned is_string($value) — a superset of ClassConstFetchAnnotationToAttributeMapper (is_string && contains '::' && not quoted). A value like Foo::BAR matched both, and the curated order let the class-const mapper win. autodiscover() filesystem order would not honor that.

Rather than a consumer change, this makes the two candidates mutually exclusive, so match order is irrelevant:

publicfunctionisCandidate(mixed$value): bool
{
if (! is_string($value)) {
returnfalse;
}
// an unquoted "Class::CONST" reference is handled by the class const fetch mapperreturn ! str_contains($value, '::') || str_starts_with($value, '"');
}

ANNOTATION_TO_ATTRIBUTE_MAPPER_CLASSES collapses to one autodiscover() call.

Verified the two mappers no longer both claim any value (behavior identical to the old first-match order):

valueclass-const mapperstring mapper
Foo::BARyesno
plainnoyes
"quoted::x"noyes

Interface added to the class-leak skip list.

@TomasVotruba
TomasVotruba merged commit e18cbc2 into mainAug 25, 2026
43 of 44 checks passed
@TomasVotruba
TomasVotruba deleted the annotationmapper-autodiscover branch August 25, 2026 07:24
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