Support more built-in types for container factory functions#303
Merged
Support more built-in types for container factory functions#303
Conversation
01a427e to
4e42238
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends FrameworkX\Container’s factory-function parameter type validation to recognize additional PHP built-in types (object, iterable, callable, true, false) so valid container values no longer incorrectly fail type checks.
Changes:
- Extend
Container::validateType()to acceptobject,iterable,callable,true, andfalseparameter types. - Add new test cases covering both successful resolution and type-mismatch errors for these types.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Container.php |
Expands runtime type validation to handle additional built-in types in factory parameters. |
tests/ContainerTest.php |
Adds test coverage for the new supported built-in types and their error messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changeset adds support for
object(PHP 7.2+),iterable,callable,true(PHP 8.2+) andfalse(PHP 8.0+ union or PHP 8.2+ standalone) types forContainerfactory function parameters. Previously, using these types would incorrectly report a type mismatch even though the values were valid.This includes 10 new test cases to verify correct type validation and error reporting for each new type. This has 100% code coverage and should be safe to apply.
Builds on top of #287, #284, #182 and others