fix(bundle): alias the nested token services with their own class - #673
Open
Spomky wants to merge 1 commit into
Open
fix(bundle): alias the nested token services with their own class#673Spomky wants to merge 1 commit into
Spomky wants to merge 1 commit into
Conversation
The nested token sources registered their autowiring alias against the class of the configuration source itself instead of the class of the service they create, so nothing could ever be autowired through `Jose\Component\NestedToken\NestedTokenLoader $<name>NestedTokenLoader` or its builder counterpart. A test walks every autowiring alias the bundle registers and checks that the aliased service is an instance of the aliased type, so the twelve other sources are covered as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #660.
NestedTokenBuilderandNestedTokenLoader(the DI sources) registered their autowiring alias againstself::class— the class of the configuration source — instead of the class of the service they create. The resulting aliases were:Nothing could ever resolve them, so autowiring a nested token loader or builder failed. They now read:
The naming convention (
<config name>+ service kind) is unchanged, and it matches every other source ($jwsLoader1JwsLoader,$builder1JweBuilder, …).Are the others affected?
No. I went through all 14
registerAliasForArgument()call sites: the twelve others pass the class of the service, andAbstractSourcepasses$definition->getClass(). Only the two nested token ones were wrong.To keep it that way,
AutowiringAliasesTestloads the bundle extension with the functional test configuration, walks every autowiring alias it registers, and asserts the aliased service is an instance of the aliased type. That covers 22 aliases across all sources today and picks up any new one automatically. It fails on both nested token aliases without the fix.NestedTokenServiceConsumerin the test bundle reproduces the report end to end: it takes both services through autowiring only, and the two new functional tests check it receives the services from the configuration.Not addressed here
The
$targetargument ofregisterAliasForArgument(), suggested in the issue's additional context, would let people write#[Target('nested_token_loader_1')]instead of the suffixed name. It landed in Symfony 7.4 and this branch supportssymfony/dependency-injection: ^7.0|^8.0, so it can't be used unconditionally here. Worth a separate issue on a branch that can raise the requirement — it applies to every source, not just these two.Test run
Full suite: 777 tests, 38 failures — the same 38 that fail on an untouched
4.1.xcheckout. They are all*ConfigurationTestcases wherematthiasnoback/symfony-config-testno longer matches the Symfony 8.1 config error messages, unrelated to this change. ECS and PHPStan cannot run on4.1.xat all (broken tool configuration, already repaired on4.2.xby #669).