Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…o `Type` constraint (Florian Hermann) This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Validator] Add `list` and `associative_array` types to `Type` constraint | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | - | License | MIT Hello! This PR aims to add support for `list` type in the `Type`constraint. This is done by using the *new* PHP 8.1 function `array_is_list`, after checking that the value is an array with `is_array` function. Here is an example of use: ```php #[Assert\Type('list')] private $value; ``` I consider doing an other PR to add `associative_array` type aswell. Or if you think it's ok, I can also add it in an other commit on this one. --- UPDATE After fabpot comment, I added an other commit to support `associative_array` type aswell : ```php #[Assert\Type('associative_array')] private $value; ``` An `associative_array` is an array that is not a list. Moreover, this means that an empty array will not be considered as an `associative_array`. Best regards Commits ------- 5ab4068 [Validator] Add `list` and `associative_array` types to `Type` constraint
- Loading branch information