Improve exception messages for Container to be more descriptive and include more details
#284
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 improves exception messages for the
Containerclass to improve type safety, error handling, and clarity of exception messages. It replaces most uses of\BadMethodCallExceptioninstances with more appropriate exception types (\TypeErrorand\Error), clarifies docblocks, and strengthens type validation throughout the container configuration and resolution logic.These changes make the DI container more robust, easier to use correctly, and provide clearer feedback when misused. On top of this, the main motivation for this is really to prepare follow-up features like union types. More on this in a follow-up PR.
Note that this only affects exception handling for invalid arguments etc. and all its APIs are currently internal, so this does not affect BC.
Builds on top of #274, #267, #244, #97, #95, #94, #92, #12 and others