diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 3dc97d5c0d3..c7e064b16ca 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -480,10 +480,10 @@ invalid answer and will only be able to proceed if their input is valid. use Symfony\Component\Validator\Validation; $question = new Question('Please enter the name of the bundle', 'AcmeDemoBundle'); - $validation = Validation::createCallable(new Regex([ - 'pattern' => '/^[a-zA-Z]+Bundle$/', - 'message' => 'The name of the bundle should be suffixed with \'Bundle\'', - ])); + $validation = Validation::createCallable(new Regex( + pattern: '/^[a-zA-Z]+Bundle$/', + message: 'The name of the bundle should be suffixed with \'Bundle\'', + )); $question->setValidator($validation); Validating a Hidden Response diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 95741a7e372..65685106c13 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -394,7 +394,7 @@ returns ``true`` for acceptable values and ``false`` for invalid values:: // ... $resolver->setAllowedValues('transport', Validation::createIsValidCallable( - new Length(['min' => 10 ]) + new Length(min: 10) )); In sub-classes, you can use :method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::addAllowedValues` diff --git a/components/validator.rst b/components/validator.rst index 085c77a7946..12c61507257 100644 --- a/components/validator.rst +++ b/components/validator.rst @@ -36,7 +36,7 @@ characters long:: $validator = Validation::createValidator(); $violations = $validator->validate('Bernhard', [ - new Length(['min' => 10]), + new Length(min: 10), new NotBlank(), ]); diff --git a/components/validator/metadata.rst b/components/validator/metadata.rst index e7df42413bc..782e1ee216f 100755 --- a/components/validator/metadata.rst +++ b/components/validator/metadata.rst @@ -24,7 +24,7 @@ the ``Author`` class has at least 3 characters:: $metadata->addPropertyConstraint('firstName', new Assert\NotBlank()); $metadata->addPropertyConstraint( 'firstName', - new Assert\Length(["min" => 3]) + new Assert\Length(min: 3) ); } } @@ -55,9 +55,9 @@ Then, add the Validator component configuration to the class:: { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addGetterConstraint('passwordSafe', new Assert\IsTrue([ - 'message' => 'The password cannot match your first name', - ])); + $metadata->addGetterConstraint('passwordSafe', new Assert\IsTrue( + message: 'The password cannot match your first name', + )); } } diff --git a/components/validator/resources.rst b/components/validator/resources.rst index 5b1448dfba1..64bf26e44d5 100644 --- a/components/validator/resources.rst +++ b/components/validator/resources.rst @@ -42,10 +42,10 @@ In this example, the validation metadata is retrieved executing the public static function loadValidatorMetadata(ClassMetadata $metadata): void { $metadata->addPropertyConstraint('name', new Assert\NotBlank()); - $metadata->addPropertyConstraint('name', new Assert\Length([ - 'min' => 5, - 'max' => 20, - ])); + $metadata->addPropertyConstraint('name', new Assert\Length( + min: 5, + max: 20, + )); } } diff --git a/controller/upload_file.rst b/controller/upload_file.rst index b3dc2d6ffd0..cff326a8e2b 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -75,14 +75,14 @@ so Symfony doesn't try to get/set its value from the related entity:: // unmapped fields can't define their validation using attributes // in the associated entity, so you can use the PHP constraint classes 'constraints' => [ - new File([ - 'maxSize' => '1024k', - 'mimeTypes' => [ + new File( + maxSize: '1024k', + mimeTypes: [ 'application/pdf', 'application/x-pdf', ], - 'mimeTypesMessage' => 'Please upload a valid PDF document', - ]) + mimeTypesMessage: 'Please upload a valid PDF document', + ) ], ]) // ... diff --git a/form/without_class.rst b/form/without_class.rst index 8b0af7cf23f..5fec7f3a663 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -96,12 +96,12 @@ but here's a short example:: { $builder ->add('firstName', TextType::class, [ - 'constraints' => new Length(['min' => 3]), + 'constraints' => new Length(min: 3), ]) ->add('lastName', TextType::class, [ 'constraints' => [ new NotBlank(), - new Length(['min' => 3]), + new Length(min: 3), ], ]) ; @@ -153,10 +153,10 @@ This can be done by setting the ``constraints`` option in the $resolver->setDefaults([ 'data_class' => null, 'constraints' => new Collection([ - 'firstName' => new Length(['min' => 3]), + 'firstName' => new Length(min: 3), 'lastName' => [ new NotBlank(), - new Length(['min' => 3]), + new Length(min: 3), ], ]), ]); diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index 3aa05b1d2d0..bfcea0dd1b5 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -79,12 +79,12 @@ entry in that array: { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('favoriteColors', new Assert\All([ - 'constraints' => [ + $metadata->addPropertyConstraint('favoriteColors', new Assert\All( + constraints: [ new Assert\NotBlank(), - new Assert\Length(['min' => 5]), + new Assert\Length(min: 5), ], - ])); + )); } } diff --git a/reference/constraints/AtLeastOneOf.rst b/reference/constraints/AtLeastOneOf.rst index 0a6ab618aa5..5c568987ec4 100644 --- a/reference/constraints/AtLeastOneOf.rst +++ b/reference/constraints/AtLeastOneOf.rst @@ -115,23 +115,23 @@ The following constraints ensure that: { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('password', new Assert\AtLeastOneOf([ - 'constraints' => [ - new Assert\Regex(['pattern' => '/#/']), - new Assert\Length(['min' => 10]), + $metadata->addPropertyConstraint('password', new Assert\AtLeastOneOf( + constraints: [ + new Assert\Regex(pattern: '/#/'), + new Assert\Length(min: 10), ], - ])); + )); - $metadata->addPropertyConstraint('grades', new Assert\AtLeastOneOf([ - 'constraints' => [ - new Assert\Count(['min' => 3]), - new Assert\All([ - 'constraints' => [ + $metadata->addPropertyConstraint('grades', new Assert\AtLeastOneOf( + constraints: [ + new Assert\Count(min: 3), + new Assert\All( + constraints: [ new Assert\GreaterThanOrEqual(5), ], - ]), + ), ], - ])); + )); } } diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 6e98e6fab98..bb3e9e797ad 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -77,12 +77,12 @@ on an object that will contain a credit card number. { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme([ - 'schemes' => [ + $metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme( + schemes: [ Assert\CardScheme::VISA, ], - 'message' => 'Your credit card number is invalid.', - ])); + message: 'Your credit card number is invalid.', + )); } } diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 5a9c365be37..bb7150adc8f 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -100,10 +100,10 @@ If your valid choice list is simple, you can pass them in directly via the new Assert\Choice(['New York', 'Berlin', 'Tokyo']) ); - $metadata->addPropertyConstraint('genre', new Assert\Choice([ - 'choices' => ['fiction', 'non-fiction'], - 'message' => 'Choose a valid genre.', - ])); + $metadata->addPropertyConstraint('genre', new Assert\Choice( + choices: ['fiction', 'non-fiction'], + message: 'Choose a valid genre.', + )); } } @@ -182,9 +182,9 @@ constraint. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('genre', new Assert\Choice([ - 'callback' => 'getGenres', - ])); + $metadata->addPropertyConstraint('genre', new Assert\Choice( + callback: 'getGenres', + )); } } @@ -250,9 +250,9 @@ you can pass the class name and the method as an array. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('genre', new Assert\Choice([ - 'callback' => [Genre::class, 'getGenres'], - ])); + $metadata->addPropertyConstraint('genre', new Assert\Choice( + callback: [Genre::class, 'getGenres'], + )); } } diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 2d16d201b17..557c6c02380 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -139,8 +139,8 @@ following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('profileData', new Assert\Collection([ - 'fields' => [ + $metadata->addPropertyConstraint('profileData', new Assert\Collection( + fields: [ 'personal_email' => new Assert\Email(), 'short_bio' => [ new Assert\NotBlank(), @@ -150,8 +150,8 @@ following: ]), ], ], - 'allowMissingFields' => true, - ])); + allowMissingFields: true, + )); } } @@ -267,15 +267,15 @@ you can do the following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('profileData', new Assert\Collection([ - 'fields' => [ + $metadata->addPropertyConstraint('profileData', new Assert\Collection( + fields: [ 'personal_email' => new Assert\Required([ new Assert\NotBlank(), new Assert\Email(), ]), 'alternate_email' => new Assert\Optional(new Assert\Email()), ], - ])); + )); } } @@ -291,28 +291,28 @@ groups. Take the following example:: use Symfony\Component\Validator\Constraints as Assert; - $constraint = new Assert\Collection([ - 'fields' => [ + $constraint = new Assert\Collection( + fields: [ 'name' => new Assert\NotBlank(['groups' => 'basic']), 'email' => new Assert\NotBlank(['groups' => 'contact']), ], - ]); + ); This will result in the following configuration:: - $constraint = new Assert\Collection([ - 'fields' => [ - 'name' => new Assert\Required([ - 'constraints' => new Assert\NotBlank(['groups' => 'basic']), - 'groups' => ['basic', 'strict'], - ]), - 'email' => new Assert\Required([ - "constraints" => new Assert\NotBlank(['groups' => 'contact']), - 'groups' => ['basic', 'strict'], - ]), + $constraint = new Assert\Collection( + fields: [ + 'name' => new Assert\Required( + constraints: new Assert\NotBlank(groups: ['basic']), + groups: ['basic', 'strict'], + ), + 'email' => new Assert\Required( + constraints: new Assert\NotBlank(groups: ['contact']), + groups: ['basic', 'strict'], + ), ], - 'groups' => ['basic', 'strict'], - ]); + groups: ['basic', 'strict'], + ); The default ``allowMissingFields`` option requires the fields in all groups. So when validating in ``contact`` group, ``$name`` can be empty but the key is diff --git a/reference/constraints/Compound.rst b/reference/constraints/Compound.rst index 0d0dc933ae0..4d2c7743176 100644 --- a/reference/constraints/Compound.rst +++ b/reference/constraints/Compound.rst @@ -35,9 +35,9 @@ you can create your own named set or requirements to be reused consistently ever return [ new Assert\NotBlank(), new Assert\Type('string'), - new Assert\Length(['min' => 12]), + new Assert\Length(min: 12), new Assert\NotCompromisedPassword(), - new Assert\PasswordStrength(['minScore' => 4]), + new Assert\PasswordStrength(minScore: 4), ]; } } diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 0bf40aca8e9..d33c54c0812 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -82,12 +82,12 @@ you might add the following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('emails', new Assert\Count([ - 'min' => 1, - 'max' => 5, - 'minMessage' => 'You must specify at least one email', - 'maxMessage' => 'You cannot specify more than {{ limit }} emails', - ])); + $metadata->addPropertyConstraint('emails', new Assert\Count( + min: 1, + max: 5, + minMessage: 'You must specify at least one email', + maxMessage: 'You cannot specify more than {{ limit }} emails', + )); } } diff --git a/reference/constraints/CssColor.rst b/reference/constraints/CssColor.rst index 88a4eb4be9f..b617ebf1c42 100644 --- a/reference/constraints/CssColor.rst +++ b/reference/constraints/CssColor.rst @@ -110,15 +110,15 @@ the named CSS colors: { $metadata->addPropertyConstraint('defaultColor', new Assert\CssColor()); - $metadata->addPropertyConstraint('accentColor', new Assert\CssColor([ - 'formats' => Assert\CssColor::HEX_LONG, - 'message' => 'The accent color must be a 6-character hexadecimal color.', - ])); - - $metadata->addPropertyConstraint('currentColor', new Assert\CssColor([ - 'formats' => [Assert\CssColor::BASIC_NAMED_COLORS, Assert\CssColor::EXTENDED_NAMED_COLORS], - 'message' => 'The color "{{ value }}" is not a valid CSS color name.', - ])); + $metadata->addPropertyConstraint('accentColor', new Assert\CssColor( + formats: Assert\CssColor::HEX_LONG, + message: 'The accent color must be a 6-character hexadecimal color.', + )); + + $metadata->addPropertyConstraint('currentColor', new Assert\CssColor( + formats: [Assert\CssColor::BASIC_NAMED_COLORS, Assert\CssColor::EXTENDED_NAMED_COLORS], + message: 'The color "{{ value }}" is not a valid CSS color name.', + )); } } diff --git a/reference/constraints/DivisibleBy.rst b/reference/constraints/DivisibleBy.rst index dd90ad9a0fd..23b36023cff 100644 --- a/reference/constraints/DivisibleBy.rst +++ b/reference/constraints/DivisibleBy.rst @@ -92,9 +92,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('weight', new Assert\DivisibleBy(0.25)); - $metadata->addPropertyConstraint('quantity', new Assert\DivisibleBy([ - 'value' => 5, - ])); + $metadata->addPropertyConstraint('quantity', new Assert\DivisibleBy( + value: 5, + )); } } diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 516d6d07dca..41012e5e935 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -70,9 +70,9 @@ Basic Usage public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('email', new Assert\Email([ - 'message' => 'The email "{{ value }}" is not a valid email.', - ])); + $metadata->addPropertyConstraint('email', new Assert\Email( + message: 'The email "{{ value }}" is not a valid email.', + )); } } diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index d5d78f60a0f..fdc402b1a97 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -91,9 +91,9 @@ and that the ``age`` is ``20``, you could do the following: { $metadata->addPropertyConstraint('firstName', new Assert\EqualTo('Mary')); - $metadata->addPropertyConstraint('age', new Assert\EqualTo([ - 'value' => 20, - ])); + $metadata->addPropertyConstraint('age', new Assert\EqualTo( + value: 20, + )); } } diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index bf015d17573..d5a78f71d5e 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -111,10 +111,10 @@ One way to accomplish this is with the Expression constraint: { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addConstraint(new Assert\Expression([ - 'expression' => 'this.getCategory() in ["php", "symfony"] or !this.isTechnicalPost()', - 'message' => 'If this is a tech post, the category should be either php or symfony!', - ])); + $metadata->addConstraint(new Assert\Expression( + expression: 'this.getCategory() in ["php", "symfony"] or !this.isTechnicalPost()', + message: 'If this is a tech post, the category should be either php or symfony!', + )); } // ... @@ -200,10 +200,10 @@ assert that the expression must return ``true`` for validation to fail. { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('isTechnicalPost', new Assert\Expression([ - 'expression' => 'this.getCategory() in ["php", "symfony"] or value == false', - 'message' => 'If this is a tech post, the category should be either php or symfony!', - ])); + $metadata->addPropertyConstraint('isTechnicalPost', new Assert\Expression( + expression: 'this.getCategory() in ["php", "symfony"] or value == false', + message: 'If this is a tech post, the category should be either php or symfony!', + )); } // ... @@ -343,10 +343,10 @@ type (numeric, boolean, strings, null, etc.) { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('metric', new Assert\Expression([ - 'expression' => 'value + error_margin < threshold', - 'values' => ['error_margin' => 0.25, 'threshold' => 1.5], - ])); + $metadata->addPropertyConstraint('metric', new Assert\Expression( + expression: 'value + error_margin < threshold', + values: ['error_margin' => 0.25, 'threshold' => 1.5], + )); } // ... diff --git a/reference/constraints/ExpressionSyntax.rst b/reference/constraints/ExpressionSyntax.rst index c1d086790c1..37e0ad7de4a 100644 --- a/reference/constraints/ExpressionSyntax.rst +++ b/reference/constraints/ExpressionSyntax.rst @@ -90,9 +90,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('promotion', new Assert\ExpressionSyntax()); - $metadata->addPropertyConstraint('shippingOptions', new Assert\ExpressionSyntax([ - 'allowedVariables' => ['user', 'shipping_centers'], - ])); + $metadata->addPropertyConstraint('shippingOptions', new Assert\ExpressionSyntax( + allowedVariables: ['user', 'shipping_centers'], + )); } } diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 6d9b72d17b8..495c19f9cbe 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -119,13 +119,13 @@ below a certain file size and a valid PDF, add the following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('bioFile', new Assert\File([ - 'maxSize' => '1024k', - 'extensions' => [ + $metadata->addPropertyConstraint('bioFile', new Assert\File( + maxSize: '1024k', + extensions: [ 'pdf', ], - 'extensionsMessage' => 'Please upload a valid PDF', - ])); + extensionsMessage: 'Please upload a valid PDF', + )); } } diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 4f2e34bcbfa..d1b79028acd 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -89,9 +89,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('siblings', new Assert\GreaterThan(5)); - $metadata->addPropertyConstraint('age', new Assert\GreaterThan([ - 'value' => 18, - ])); + $metadata->addPropertyConstraint('age', new Assert\GreaterThan( + value: 18, + )); } } diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index e5a71e5f788..63c2ade6197 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -88,9 +88,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('siblings', new Assert\GreaterThanOrEqual(5)); - $metadata->addPropertyConstraint('age', new Assert\GreaterThanOrEqual([ - 'value' => 18, - ])); + $metadata->addPropertyConstraint('age', new Assert\GreaterThanOrEqual( + value: 18, + )); } } diff --git a/reference/constraints/Hostname.rst b/reference/constraints/Hostname.rst index 95b10d1736e..58ac0364669 100644 --- a/reference/constraints/Hostname.rst +++ b/reference/constraints/Hostname.rst @@ -72,9 +72,9 @@ will contain a host name. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('name', new Assert\Hostname([ - 'message' => 'The server name must be a valid hostname.', - ])); + $metadata->addPropertyConstraint('name', new Assert\Hostname( + message: 'The server name must be a valid hostname.', + )); } } diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index 3cf800200e2..8d5982eea6d 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -77,9 +77,9 @@ will contain an International Bank Account Number. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('bankAccountNumber', new Assert\Iban([ - 'message' => 'This is not a valid International Bank Account Number (IBAN).', - ])); + $metadata->addPropertyConstraint('bankAccountNumber', new Assert\Iban( + message: 'This is not a valid International Bank Account Number (IBAN).', + )); } } diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index 5b6d853dc0b..f8844f90a72 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -94,9 +94,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('firstName', new Assert\IdenticalTo('Mary')); - $metadata->addPropertyConstraint('age', new Assert\IdenticalTo([ - 'value' => 20, - ])); + $metadata->addPropertyConstraint('age', new Assert\IdenticalTo( + value: 20, + )); } } diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index 23fbe5a157a..5dd270c44f8 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -116,12 +116,12 @@ that it is between a certain size, add the following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('headshot', new Assert\Image([ - 'minWidth' => 200, - 'maxWidth' => 400, - 'minHeight' => 200, - 'maxHeight' => 400, - ])); + $metadata->addPropertyConstraint('headshot', new Assert\Image( + minWidth: 200, + maxWidth: 400, + minHeight: 200, + maxHeight: 400, + )); } } @@ -187,10 +187,10 @@ following code: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('headshot', new Assert\Image([ - 'allowLandscape' => false, - 'allowPortrait' => false, - ])); + $metadata->addPropertyConstraint('headshot', new Assert\Image( + allowLandscape: false, + allowPortrait: false, + )); } } diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 0b9ebe77491..3d0a1665944 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -93,9 +93,9 @@ method returns **false**: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addGetterConstraint('stateInvalid', new Assert\IsFalse([ - 'message' => "You've entered an invalid state.", - ])); + $metadata->addGetterConstraint('stateInvalid', new Assert\IsFalse( + message: "You've entered an invalid state.", + )); } public function isStateInvalid(): bool diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index 678371f6e69..b50ba4f3e8b 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -97,9 +97,9 @@ Then you can validate this method with ``IsTrue`` as follows: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addGetterConstraint('tokenValid', new IsTrue([ - 'message' => 'The token is invalid.', - ])); + $metadata->addGetterConstraint('tokenValid', new IsTrue( + message: 'The token is invalid.', + )); } public function isTokenValid(): bool diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index 954bff233d5..52d10565fe5 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -76,10 +76,10 @@ on an object that will contain an ISBN. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('isbn', new Assert\Isbn([ - 'type' => Assert\Isbn::ISBN_10, - 'message' => 'This value is not valid.', - ])); + $metadata->addPropertyConstraint('isbn', new Assert\Isbn( + type: Assert\Isbn::ISBN_10, + message: 'This value is not valid.', + )); } } diff --git a/reference/constraints/Json.rst b/reference/constraints/Json.rst index 28e15976f3c..337b2dc6a1e 100644 --- a/reference/constraints/Json.rst +++ b/reference/constraints/Json.rst @@ -69,9 +69,9 @@ The ``Json`` constraint can be applied to a property or a "getter" method: { public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('chapters', new Assert\Json([ - 'message' => 'You\'ve entered an invalid Json.', - ])); + $metadata->addPropertyConstraint('chapters', new Assert\Json( + message: 'You\'ve entered an invalid Json.', + )); } } diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 9a4478f509b..c1a8575070b 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -85,12 +85,12 @@ and ``50``, you might add the following: public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('firstName', new Assert\Length([ - 'min' => 2, - 'max' => 50, - 'minMessage' => 'Your first name must be at least {{ limit }} characters long', - 'maxMessage' => 'Your first name cannot be longer than {{ limit }} characters', - ])); + $metadata->addPropertyConstraint('firstName', new Assert\Length( + min: 2, + max: 50, + minMessage: 'Your first name must be at least {{ limit }} characters long', + maxMessage: 'Your first name cannot be longer than {{ limit }} characters', + )); } } diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index 964bfbb3527..3d23bcda445 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -89,9 +89,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('siblings', new Assert\LessThan(5)); - $metadata->addPropertyConstraint('age', new Assert\LessThan([ - 'value' => 80, - ])); + $metadata->addPropertyConstraint('age', new Assert\LessThan( + value: 80, + )); } } diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 9420c3e4376..ac66c62d7d0 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -88,9 +88,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('siblings', new Assert\LessThanOrEqual(5)); - $metadata->addPropertyConstraint('age', new Assert\LessThanOrEqual([ - 'value' => 80, - ])); + $metadata->addPropertyConstraint('age', new Assert\LessThanOrEqual( + value: 80, + )); } } diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index 49edd473d05..4bba45ae12b 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -78,9 +78,9 @@ Basic Usage public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('locale', new Assert\Locale([ - 'canonicalize' => true, - ])); + $metadata->addPropertyConstraint('locale', new Assert\Locale( + canonicalize: true, + )); } } diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 8f5ef34c4ba..0c835204091 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -72,9 +72,9 @@ will contain a credit card number. public static function loadValidatorMetadata(ClassMetadata $metadata): void { - $metadata->addPropertyConstraint('cardNumber', new Assert\Luhn([ - 'message' => 'Please check your credit card number', - ])); + $metadata->addPropertyConstraint('cardNumber', new Assert\Luhn( + message: 'Please check your credit card number', + )); } } diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index b8ee4cac32f..dd3f633b4a1 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -93,9 +93,9 @@ the following: { $metadata->addPropertyConstraint('firstName', new Assert\NotEqualTo('Mary')); - $metadata->addPropertyConstraint('age', new Assert\NotEqualTo([ - 'value' => 15, - ])); + $metadata->addPropertyConstraint('age', new Assert\NotEqualTo( + value: 15, + )); } } diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 9ea93dc4b86..b2c20027292 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -94,9 +94,9 @@ The following constraints ensure that: { $metadata->addPropertyConstraint('age', new Assert\NotIdenticalTo('Mary')); - $metadata->addPropertyConstraint('age', new Assert\NotIdenticalTo([ - 'value' => 15, - ])); + $metadata->addPropertyConstraint('age', new Assert\NotIdenticalTo( + value: 15, + )); } } diff --git a/reference/constraints/PasswordStrength.rst b/reference/constraints/PasswordStrength.rst index 60125a763a1..0b242cacf08 100644 --- a/reference/constraints/PasswordStrength.rst +++ b/reference/constraints/PasswordStrength.rst @@ -101,9 +101,9 @@ or by a custom password strength estimator. class User { - #[Assert\PasswordStrength([ - 'minScore' => PasswordStrength::STRENGTH_VERY_STRONG, // Very strong password required - ])] + #[Assert\PasswordStrength( + minScore: PasswordStrength::STRENGTH_VERY_STRONG, // Very strong password required + )] protected $rawPassword; } @@ -123,9 +123,9 @@ The default message supplied when the password does not reach the minimum requir class User { - #[Assert\PasswordStrength([ - 'message' => 'Your password is too easy to guess. Company\'s security policy requires to use a stronger password.' - ])] + #[Assert\PasswordStrength( + message: 'Your password is too easy to guess. Company\'s security policy requires to use a stronger password.' + )] protected $rawPassword; }