Skip to content

Improve set() defaults and refresh README examples#7

Merged
ChiragAgg5k merged 1 commit intomainfrom
fix/default-empty-dependencies-and-readme
Mar 13, 2026
Merged

Improve set() defaults and refresh README examples#7
ChiragAgg5k merged 1 commit intomainfrom
fix/default-empty-dependencies-and-readme

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Mar 13, 2026

Summary

  • default Container::set() dependencies to an empty array for zero-dependency factories
  • add test coverage for calling set() without the third argument
  • update README examples to match the current container API and child-container usage

Testing

  • php ./vendor/bin/phpunit tests/ContainerTest.php

Summary by CodeRabbit

  • Documentation

    • Updated README with simplified factory registration examples, demonstrating optional dependencies parameter and direct closure-based registration syntax.
  • Tests

    • Added test case confirming the dependencies array parameter defaults to an empty list, allowing factories to be registered with minimal required arguments.

@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c61324e0-42b4-4327-9c1a-90b5bdcfd2d5

📥 Commits

Reviewing files that changed from the base of the PR and between 72e1a3e and d2be6ae.

📒 Files selected for processing (3)
  • README.md
  • src/DI/Container.php
  • tests/ContainerTest.php

Walkthrough

The changes make the $dependencies parameter optional in the Container's set() method by providing a default empty array. The README documentation is updated to reflect this shorthand functional factory registration pattern using direct closures rather than explicit Dependency objects. A new test case verifies that the set() method works correctly when called without the optional dependencies parameter.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/default-empty-dependencies-and-readme
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChiragAgg5k ChiragAgg5k merged commit 68873b7 into main Mar 13, 2026
6 of 7 checks passed
@ChiragAgg5k ChiragAgg5k deleted the fix/default-empty-dependencies-and-readme branch March 13, 2026 05:47
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