-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[spiral/core] Advanced Context Handling in Injector Implementations #1041
Merged
Conversation
This file contains 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
…ng context; pass \ReflectionParameter in extended Injectors
[ci skip] [skip ci]
😟 |
Merged
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1041 +/- ##
============================================
- Coverage 89.51% 89.49% -0.03%
- Complexity 6234 6238 +4
============================================
Files 819 819
Lines 17555 17568 +13
============================================
+ Hits 15714 15722 +8
- Misses 1841 1846 +5 ☔ View full report in Codecov by Sentry. |
wolfy-j
approved these changes
Jan 2, 2024
butschster
approved these changes
Jan 3, 2024
butschster
changed the title
Extended injector
Advanced Context Handling in Injector Implementations
Jan 5, 2024
butschster
changed the title
Advanced Context Handling in Injector Implementations
[spiral/core] Advanced Context Handling in Injector Implementations
Jan 5, 2024
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.
Injectors
This pull request presents a significant update to the injector system, focusing on the
createInjection
method of theSpiral\Core\Container\InjectorInterface
. The key enhancement lies in the augmented ability of the injector to handle context more effectively.Previously, the
createInjection
method accepted two parameters: theReflectionClass
object of the requested class and a context, which was limited to being either astring
ornull
. This approach, while functional, offered limited flexibility in dynamically resolving dependencies based on the calling context.The updated
createInjection
method can now accept an extended range of context types includingStringable|string|null
,mixed
, orReflectionParameter|string|null
. This broadening allows the injector to receive more detailed contextual information, enhancing its capability to make more informed decisions about which implementation to provide.Now you can do something like this:
And example of injector
Container Factory
Now the container factory accepts a
Stringable
context. This can be either reflection or any otherStringable
.Other container methods with an extended context will be available in a separate PR.