[TASK] Update cuyz/valinor to v2.4.0#134
Merged
renovate[bot] merged 1 commit intomainfrom Mar 24, 2026
Merged
Conversation
| datasource | package | from | to | | ---------- | ------------ | ----- | ----- | | packagist | cuyz/valinor | 2.3.2 | 2.4.0 |
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 PR contains the following updates:
2.3.2→2.4.0Release Notes
CuyZ/Valinor (cuyz/valinor)
v2.4.0Compare Source
Notable changes
This release brings a whole set of new features to the library:
Enjoy! 🎉
HTTP request mapping support
This library now provides a way to map an HTTP request to controller action parameters or object properties. Parameters can be mapped from route, query and body values.
Three attributes are available to explicitly bind a parameter to a single source, ensuring the value is never resolved from the wrong source:
#[FromRoute]— for parameters extracted from the URL path by router#[FromQuery]— for query string parameters#[FromBody]— for request body valuesThose attributes can be omitted entirely if the parameter is not bound to a specific source, in which case a collision error is raised if the same key is found in more than one source.
This gives controllers a clean, type-safe signature without coupling to a framework's request object, while benefiting from the library's validation and error handling.
Normal mapping rules apply there: parameters are required unless they have a default value.
Route and query parameter values coming from an HTTP request are typically strings. The mapper automatically handles scalar value casting for these parameters: a string
"42"will be properly mapped to anintparameter.Mapping a request using attributes
Consider an API that lists articles for a given author. The author identifier comes from the URL path, while filtering and pagination come from the query string.
Mapping a request without using attributes
When it is unnecessary to distinguish which source a parameter comes from, the attribute can be omitted entirely — the mapper will resolve each parameter from whichever source contains the matching key.
Mapping all parameters at once
Instead of mapping individual query parameters or body values to separate parameters, the
asRootoption can be used to map all of them at once to a single parameter. This is useful when working with complex data structures or when the number of parameters is large.The same approach works with
#[FromBody(asRoot: true)]for body values.Mapping to an object
Instead of mapping to a callable's arguments, an
HttpRequestcan be mapped directly to an object. The attributes work the same way on constructor parameters or promoted properties.Using PSR-7 requests
An
HttpRequestinstance can be built directly from a PSR-7ServerRequestInterface. This is the recommended approach when integrating with frameworks that use PSR-7.The factory method extracts query parameters from
getQueryParams()and body values fromgetParsedBody(). It also passes the original PSR-7 request object through, so it can be injected into controller parameters if needed (see below).Accessing the original request object
When building an
HttpRequest, an original request object can be provided. If a controller parameter's type matches this object, it will be injected automatically; no attribute is needed.Error handling
When the mapping fails — for instance because a required query parameter is missing or a body value has the wrong type — a
MappingErroris thrown, just like with regular mapping.Read the validation and error handling chapter for more information.
Mapper/Normalizer configurators support
Introduce
MapperBuilderConfiguratorandNormalizerBuilderConfiguratorinterfaces along with aconfigureWith()method on both builders.A configurator is a reusable piece of configuration logic that can be applied to a
MapperBuilderor aNormalizerBuilderinstance. This is useful when the same configuration needs to be applied in multiple places across an application, or when configuration logic needs to be distributed as a package.In the example below, we apply two configuration settings to a
MapperBuilderinside a single class, but this could contain any number of customizations, depending on the needs of the application.This configurator can be registered within the
MapperBuilderinstance:Composing multiple configurators
Multiple configurators can be combined to compose the final configuration. Each configurator is applied in order, allowing layered and modular configuration.
This approach keeps each configurator focused on a single concern, making them easier to test and reuse independently.
Using
NormalizerBuilderConfiguratorThe same configurator logic can be applied on
NormalizerBuilder:CamelCase/snake_case keys conversion support
Two configurators are available to convert the keys of input data before mapping them to object properties or shaped array keys. This allows accepting data with a different naming convention than the one used in the PHP codebase.
ConvertKeysToCamelCasefirst_name→firstNameFirstName→firstNamefirst-name→firstNameConvertKeysToSnakeCasefirstName→first_nameFirstName→first_namefirst-name→first_nameThis configurator can be combined with a key restriction configurator to both validate and convert keys in a single step. The restriction configurator must be registered before the conversion so that the validation runs on the original input keys.
Keys case restriction support
Four configurators restrict which key case is accepted when mapping input data to objects or shaped arrays. If a key does not match the expected case, a mapping error will be raised.
This is useful, for instance, to enforce a consistent naming convention across an API's input to ensure that a JSON payload only contains
camelCase,snake_case,PascalCaseorkebab-casekeys.Available configurators:
new RestrictKeysToCamelCase()firstNamenew RestrictKeysToPascalCase()FirstNamenew RestrictKeysToSnakeCase()first_namenew RestrictKeysToKebabCase()first-nameFeatures
Bug Fixes
FileWatchingCache(d445e4)Internal
Deps
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.