Skip to content

Fix bugs, remove dead code, and refactor Config internals#74

Merged
alganet merged 1 commit intoRespect:masterfrom
alganet:autoref
Mar 21, 2026
Merged

Fix bugs, remove dead code, and refactor Config internals#74
alganet merged 1 commit intoRespect:masterfrom
alganet:autoref

Conversation

@alganet
Copy link
Member

@alganet alganet commented Mar 21, 2026

  • Fix empty("0") treating "0" as null in IniLoader::parseValue
  • Fix pre-existing bug: matchConstructorParam no longer pollutes constructor array with null placeholders, allowing params with non-nullable defaults (e.g. EntityFactory::$style) to work
  • Add numeric coercion in parseConstants for strict_types compat
  • Add declare(strict_types=1) to Instantiator.php
  • Guard Autowire::cleanupParams to only autowire constructor params, not method-call arguments
  • Remove Container::__invoke and __call (unused by consumers)
  • Extract shouldCache() to replace $forceNew param in getInstance; Factory overrides to return false instead of wrapping parent call
  • Extract stripTrailingNulls helper, deduplicating Autowire/Instantiator
  • Refactor keyHasStateInstance to existingKeyFrom (no side-effect)
  • Cache plain callables consistently in lazyLoad
  • Remove func_get_args(), stripos, and dead imports
  • Use parent::offsetGet in has() for consistency

@alganet alganet marked this pull request as ready for review March 21, 2026 04:23
@alganet alganet requested a review from Copilot March 21, 2026 04:23
@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2026

Codecov Report

❌ Patch coverage is 98.86364% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.34%. Comparing base (e744aa2) to head (6fbdcae).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/IniLoader.php 95.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              master      #74      +/-   ##
=============================================
- Coverage     100.00%   99.34%   -0.66%     
- Complexity       155      157       +2     
=============================================
  Files              6        6              
  Lines            319      306      -13     
=============================================
- Hits             319      304      -15     
- Misses             0        2       +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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR focuses on fixing a few configuration/instantiation edge cases while refactoring the container/instantiator internals to simplify caching behavior and remove unused magic-call APIs.

Changes:

  • Refactor Instantiator caching and parameter cleanup (shouldCache(), stripTrailingNulls()), and update Factory to opt out of caching.
  • Fix/adjust INI parsing semantics (empty("0") no longer treated as null; add numeric coercion in constant parsing; refactor state precedence handling).
  • Remove unused Container::__invoke/__call paths and tighten Autowire constructor-only autowiring (with new nesting/container-propagation tests).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Instantiator.php Introduces shouldCache(), refactors instance caching + param cleanup, and removes dead/legacy logic.
src/Factory.php Switches Factory behavior to “never cache” via shouldCache(): false.
src/Container.php Removes magic invoke/call APIs and updates lazy-loading/caching logic (including plain callables).
src/IniLoader.php Fixes empty-string handling, refactors state precedence, and adds numeric coercion in constant parsing.
src/Autowire.php Ensures autowiring happens only for constructor params and propagates container into nested autowires.
tests/AutowireTest.php Adds coverage for nested/deeply nested autowire container propagation.
tests/FactoryTest.php Removes obsolete force-new test aligned with the new caching API.
tests/ContainerTest.php Removes tests for APIs that were deleted (__invoke, __call).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix empty("0") treating "0" as null in IniLoader::parseValue
- Fix pre-existing bug: matchConstructorParam no longer pollutes
  constructor array with null placeholders, allowing params with
  non-nullable defaults (e.g. EntityFactory::$style) to work
- Add numeric coercion in parseConstants for strict_types compat
- Add declare(strict_types=1) to Instantiator.php
- Guard Autowire::cleanupParams to only autowire constructor params,
  not method-call arguments
- Remove Container::__invoke and __call (unused by consumers)
- Extract shouldCache() to replace $forceNew param in getInstance;
  Factory overrides to return false instead of wrapping parent call
- Extract stripTrailingNulls helper, deduplicating Autowire/Instantiator
- Refactor keyHasStateInstance to existingKeyFrom (no side-effect)
- Cache plain callables consistently in lazyLoad
- Remove func_get_args(), stripos, and dead imports
- Use parent::offsetGet in has() for consistency
@alganet alganet merged commit 8bb8475 into Respect:master Mar 21, 2026
3 checks passed
@alganet alganet deleted the autoref branch March 21, 2026 05:06
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.

3 participants