Align compiled singleton PostConstruct lifecycle#138
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughCompiled injectors now cache the injector instance during wakeup. Singleton instances are cached before ChangesSingleton lifecycle handling
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 1.x #138 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 95 99 +4
===========================================
Files 11 11
Lines 238 253 +15
===========================================
+ Hits 238 253 +15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
PostConstruct, matching Ray.Di runtime semanticsCompiledInjectorits ownInjectorInterfacesingleton so lifecycle re-entry uses the same singleton cachePostConstructthrows, allowing a clean retryRoot cause
Generated singleton scripts cached instances only after
PostConstructcompleted. A lifecycle method that resolved a dependency back to the singleton therefore started constructing the same object again. In addition, injectedInjectorInterfacevalues were separateCompiledInjectorinstances, so re-entry did not share the active injector's singleton cache.Behavior
The generated script now provisionally caches the constructed singleton, invokes
PostConstruct, and removes that entry before rethrowing anyThrowable. This rollback is intentionally local to the singleton whose lifecycle method failed. Other successfully created singletons and external side effects are not treated as a transaction, consistent with the container's existing resolution model.Validation
composer cs-fixcomposer cscomposer test— 99 tests, 187 assertionscomposer coverage— 100% classes, methods, and linescomposer testsreaches Psalm through its PHP 8.5 shebang and currently stops on Psalm's own deprecatedSplObjectStorage::attach()call. Running the same Psalm binary explicitly with PHP 8.4 succeeds; the PHPUnit, coding-standard, and PHPStan phases also pass independently on PHP 8.5.Summary by CodeRabbit
Bug Fixes
Tests