09: Loader resolution and registration - #9
Open
nikolaystrikhar wants to merge 1 commit into
Open
Conversation
nikolaystrikhar
force-pushed
the
08-registrar
branch
from
August 6, 2026 14:22
62f5859 to
73d7de8
Compare
nikolaystrikhar
force-pushed
the
09-loader-resolve
branch
from
August 6, 2026 14:22
084004a to
bdb09e3
Compare
Contributor
Author
|
@d4mation I don't think I like the static approach here as it will contain more logic.. In the end, I want to give it all to Justin to review the architecture as it's the first lib I'm working on and he has better ideas on consistensy and approaches. |
nikolaystrikhar
force-pushed
the
08-registrar
branch
from
August 11, 2026 09:45
73d7de8 to
ecd2d61
Compare
nikolaystrikhar
force-pushed
the
09-loader-resolve
branch
from
August 11, 2026 10:47
bdb09e3 to
73a4106
Compare
Loader::register() buffers the Sub_Plugin it builds rather than handing it straight to the registrar, and the buffer drains on the first read. Resolving inside register() pinned the default registrar at the host's first registration, so a container set afterwards was silently ignored; buffering makes Config::set_container() order-independent, like every other configuration call. The registrar stays the single source of truth for duplicate-slug detection and ordering, so that collision is now reported at boot rather than at the second register() call. An unusable config array is still rejected on the spot, where the host's own stack trace points at it. There is no Loader::reset(): Registrar_Interface carries no reset() to call, and a reset on the facade would be API the library supports forever for the suite's benefit. The suite clears the statics through tests/_support/Loader_State.php.
nikolaystrikhar
force-pushed
the
09-loader-resolve
branch
from
August 11, 2026 15:27
73a4106 to
9f3a2d8
Compare
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.
What:
Loaderresolves its interface-backed collaborators — from the container when one is bound, else a plainnew— and buffers registrations until boot.Usage:
Why this way: resolving inside
register()pinned the default registrar at the host's first registration, so a container set afterwards was silently dropped — and the fix for that was a documented ordering rule nobody would read until it bit them. Buffering the builtSub_Pluginand draining it on the first read costs one array and makesset_container()order-independent like every other configuration call. The registrar keeps sole ownership of duplicate-slug detection and ordering rather than the buffer restating them, and the price of that is a duplicate slug being reported at boot instead of at the secondregister()call; an unusable config array is still rejected insideregister(), where the host's stack trace points at it. There is noLoader::reset()—Registrar_Interfacehas noreset()to call, and a reset on the facade would be permanent public API bought for the test suite, so the statics are cleared by reflection fromtests/_support/Loader_State.php.Verify:
slic run unit tests/unit/LoaderResolveTest.php(21 tests, 20 of them cases) andcomposer test:analysis. Both suite legs pass. Not covered here:boot(), the hook wiring and the load loop, which are #11; the container is only exercised throughRegistrar_Interface, since the other three collaborators do not exist yet.