Skip to content

Extract Autowire utility for shared eligibility checks#79

Merged
Firehed merged 3 commits intomainfrom
refactor/extract-autowire-utility
Mar 14, 2026
Merged

Extract Autowire utility for shared eligibility checks#79
Firehed merged 3 commits intomainfrom
refactor/extract-autowire-utility

Conversation

@Firehed
Copy link
Copy Markdown
Owner

@Firehed Firehed commented Mar 14, 2026

Summary

  • Extracts autowire eligibility logic into a reusable Autowire class
  • Updates DevContainer and AutowiredValue to use the shared utility
  • Filters out Closure and Generator types which cannot be autowired

API

// Check if a class can be fully autowired
Autowire::isEligible(MyService::class); // bool

// Check if a single parameter can be autowired  
Autowire::isParameterAutowirable($reflectionParam); // bool

// Get the type name for a required param (throws if not autowirable)
Autowire::getRequiredDependencyType($param, $declaringClass); // class-string

Motivation

This prepares for #77 (config generator) which needs to check autowire eligibility. Rather than duplicate the logic, this extracts it into a shared utility that all autowiring code can use.

Test plan

  • Existing tests pass (DevContainer, Compiler behavior unchanged)
  • New unit tests for Autowire utility

🤖 Generated with Claude Code

Consolidates autowire eligibility logic into a reusable Autowire class:
- getRequiredDependencyType() validates and returns the type for required params
- isParameterAutowirable() checks if a param can be autowired (boolean)
- isEligible() checks if a class can be fully autowired

Updates DevContainer and AutowiredValue to use the shared utility,
reducing code duplication and ensuring consistent behavior.

Also filters out Closure and Generator types which cannot meaningfully
be autowired from a container.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.00%. Comparing base (acf276d) to head (20e14a8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #79      +/-   ##
============================================
+ Coverage     80.97%   82.00%   +1.03%     
- Complexity      196      207      +11     
============================================
  Files            26       27       +1     
  Lines           594      617      +23     
============================================
+ Hits            481      506      +25     
+ Misses          113      111       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Firehed and others added 2 commits March 14, 2026 10:03
Add tests for isParameterAutowirable() and getRequiredDependencyType()
methods, including exception cases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for edge cases:
- No type hint parameters
- Union type parameters
- Private constructor classes

Remove redundant isPublic() check since isInstantiable() already
handles non-public constructors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Firehed Firehed force-pushed the refactor/extract-autowire-utility branch from 178d816 to 20e14a8 Compare March 14, 2026 17:12
@Firehed Firehed merged commit 029055c into main Mar 14, 2026
18 checks passed
@Firehed Firehed deleted the refactor/extract-autowire-utility branch March 14, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant