Skip to content
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

Provider injection with Set attribute #262

Merged
merged 12 commits into from
Mar 2, 2022
Merged

Provider injection with Set attribute #262

merged 12 commits into from
Mar 2, 2022

Conversation

koriym
Copy link
Member

@koriym koriym commented Mar 1, 2022

This PR supports the injection of lazily instantiated objects.

closes #261

* "パラメーターのアノテーション"は無いのでパラメーター指定もなく、インジェクションポイントからアノテーションを読みに行くのも煩雑で一旦(リクエストない限り)PHP8のアトリビュートのみ対応

Provider injection

#[Set(FooInterface)] Proider $fooProvider

Multibinder

#[Set(FooInterface)] Map $foos

@codecov
Copy link

codecov bot commented Mar 1, 2022

Codecov Report

Merging #262 (f495a6a) into 2.x (e477dac) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##                 2.x      #262   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       320       324    +4     
===========================================
  Files             37        40    +3     
  Lines            826       842   +16     
===========================================
+ Hits             826       842   +16     
Impacted Files Coverage Δ
src/di/Name.php 100.00% <ø> (ø)
src/di/Di/Set.php 100.00% <100.00%> (ø)
src/di/Injector.php 100.00% <100.00%> (ø)
src/di/ProviderSetModule.php 100.00% <100.00%> (ø)
src/di/ProviderSetProvider.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e477dac...f495a6a. Read the comment docs.

@koriym koriym marked this pull request as draft March 1, 2022 14:57
Copy link
Member

@NaokiTsuchiya NaokiTsuchiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set 以外は既存の機能(モジュールとProvider)を利用して実現できているのがすごいです!

@koriym
Copy link
Member Author

koriym commented Mar 1, 2022

動的ファクトリー生成のインジェクトがたったこれだけで書けるのかという

@koriym koriym marked this pull request as ready for review March 2, 2022 00:31
@koriym koriym changed the title Inject Provider with Set attribute Provider injection with Set attribute Mar 2, 2022
@@ -38,6 +38,7 @@ public function __construct($module = null, string $tmpDir = '')

$module = $module ?? new NullModule();
$module->install(new AssistedModule());
$module->install(new InjectingProviderModule());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これだけ!

tests/di/Fake/FakeSet.php Outdated Show resolved Hide resolved
Co-authored-by: Naoki Tsuchiya <ntsuchiya1105@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented Mar 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@koriym koriym mentioned this pull request Mar 2, 2022
@koriym koriym merged commit 5c5bb87 into ray-di:2.x Mar 2, 2022
@koriym koriym deleted the provider branch March 2, 2022 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lazy instance injection
2 participants