function Collection::__construct
Same name in this branch
- 11.1.x vendor/ramsey/collection/src/Collection.php \Ramsey\Collection\Collection::__construct()
- 11.1.x vendor/phpdocumentor/type-resolver/src/Types/Collection.php \phpDocumentor\Reflection\Types\Collection::__construct()
Parameters
array<string,Constraint>|array<string,mixed>|null $fields An associative array defining keys in the collection and their constraints:
string[]|null $groups:
bool|null $allowExtraFields Whether to allow additional keys not declared in the configured fields (defaults to false):
bool|null $allowMissingFields Whether to allow the collection to lack some fields declared in the configured fields (defaults to false):
Overrides Composite::__construct
File
-
vendor/
symfony/ validator/ Constraints/ Collection.php, line 44
Class
- Collection
- Validates a collection with constraints defined for specific keys.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(mixed $fields = null, ?array $groups = null, mixed $payload = null, ?bool $allowExtraFields = null, ?bool $allowMissingFields = null, ?string $extraFieldsMessage = null, ?string $missingFieldsMessage = null) {
if (self::isFieldsOption($fields)) {
$fields = [
'fields' => $fields,
];
}
parent::__construct($fields, $groups, $payload);
$this->allowExtraFields = $allowExtraFields ?? $this->allowExtraFields;
$this->allowMissingFields = $allowMissingFields ?? $this->allowMissingFields;
$this->extraFieldsMessage = $extraFieldsMessage ?? $this->extraFieldsMessage;
$this->missingFieldsMessage = $missingFieldsMessage ?? $this->missingFieldsMessage;
}