Support array type for container variables and factory functions#306
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends FrameworkX\Container to accept PHP array values as container variables and to allow injecting/validating array-typed parameters in factory functions, aligning runtime behavior with expected PHP built-in types.
Changes:
- Allow
arrayvalues in container variable configuration and in variable factory return validation. - Extend factory-function parameter type validation to support the
arraybuilt-in type. - Add/adjust PHPUnit coverage for
arrayinteractions (includingiterable,callable, andgetEnv()error paths) and update docs accordingly.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
src/Container.php |
Permits array values for container variables and adds array handling in validateType() and related type assertions/messages. |
tests/ContainerTest.php |
Updates existing tests and adds new cases to cover arrays in variables and factory functions, plus getEnv() cases. |
docs/best-practices/controllers.md |
Documents that container variables / factory return values may be array in addition to object/scalar/null. |
💡 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 the
arraytype forContainervariables and factory function parameters and return values. Previously, providing anarrayas a container variable or returning one from a factory function would throw aTypeError, even thougharrayis a valid type.This includes new test cases covering
arrayvalues for container variables and factory functions, plus the interactions with the existingiterableandcallabletypes and thegetEnv()error path. This has 100% code coverage and should be safe to apply.Builds on top of #303, #284, #182 and others