Skip to content

Commit f9b47a0

Browse files
committed
minor symfony#58049 [Validator] Add more precise PHPDoc on constraints (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- [Validator] Add more precise PHPDoc on constraints | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Commits ------- 923b0c6 [Validator] Add more precise PHPDoc
2 parents beca579 + 923b0c6 commit f9b47a0

File tree

15 files changed

+59
-51
lines changed

15 files changed

+59
-51
lines changed

src/Symfony/Component/Validator/Constraints/CardScheme.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class CardScheme extends Constraint
4747
public array|string|null $schemes = null;
4848

4949
/**
50-
* @param string|string[]|array<string,mixed>|null $schemes Name(s) of the number scheme(s) used to validate the credit card number
51-
* @param string[]|null $groups
52-
* @param array<string,mixed> $options
50+
* @param non-empty-string|non-empty-string[]|array<string,mixed>|null $schemes Name(s) of the number scheme(s) used to validate the credit card number
51+
* @param string[]|null $groups
52+
* @param array<string,mixed> $options
5353
*/
5454
public function __construct(array|string|null $schemes, ?string $message = null, ?array $groups = null, mixed $payload = null, array $options = [])
5555
{

src/Symfony/Component/Validator/Constraints/Cascade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class Cascade extends Constraint
2525
public array $exclude = [];
2626

2727
/**
28-
* @param string[]|string|array<string,mixed>|null $exclude Properties excluded from validation
29-
* @param array<string,mixed>|null $options
28+
* @param non-empty-string[]|non-empty-string|array<string,mixed>|null $exclude Properties excluded from validation
29+
* @param array<string,mixed>|null $options
3030
*/
3131
public function __construct(array|string|null $exclude = null, ?array $options = null)
3232
{

src/Symfony/Component/Validator/Constraints/Choice.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function getDefaultOption(): ?string
5454
* @param callable|string|null $callback Callback method to use instead of the choice option to get the choices
5555
* @param bool|null $multiple Whether to expect the value to be an array of valid choices (defaults to false)
5656
* @param bool|null $strict This option defaults to true and should not be used
57-
* @param int|null $min Minimum of valid choices if multiple values are expected
58-
* @param int|null $max Maximum of valid choices if multiple values are expected
57+
* @param int<0, max>|null $min Minimum of valid choices if multiple values are expected
58+
* @param positive-int|null $max Maximum of valid choices if multiple values are expected
5959
* @param string[]|null $groups
6060
* @param bool|null $match Whether to validate the values are part of the choices or not (defaults to true)
6161
*/

src/Symfony/Component/Validator/Constraints/Count.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class Count extends Constraint
4343
public ?int $divisibleBy = null;
4444

4545
/**
46-
* @param int|array<string,mixed>|null $exactly The exact expected number of elements
47-
* @param int|null $min Minimum expected number of elements
48-
* @param int|null $max Maximum expected number of elements
49-
* @param int|null $divisibleBy The number the collection count should be divisible by
50-
* @param string[]|null $groups
51-
* @param array<mixed,string> $options
46+
* @param int<0, max>|array<string,mixed>|null $exactly The exact expected number of elements
47+
* @param int<0, max>|null $min Minimum expected number of elements
48+
* @param positive-int|null $max Maximum expected number of elements
49+
* @param positive-int|null $divisibleBy The number the collection count should be divisible by
50+
* @param string[]|null $groups
51+
* @param array<mixed,string> $options
5252
*/
5353
public function __construct(
5454
int|array|null $exactly = null,

src/Symfony/Component/Validator/Constraints/CssColor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ class CssColor extends Constraint
6262
public array|string $formats;
6363

6464
/**
65-
* @param string[]|string|array<string,mixed> $formats The types of CSS colors allowed ({@see https://symfony.com/doc/current/reference/constraints/CssColor.html#formats})
66-
* @param string[]|null $groups
67-
* @param array<string,mixed>|null $options
65+
* @param non-empty-string[]|non-empty-string|array<string,mixed> $formats The types of CSS colors allowed ({@see https://symfony.com/doc/current/reference/constraints/CssColor.html#formats})
66+
* @param string[]|null $groups
67+
* @param array<string,mixed>|null $options
6868
*/
6969
public function __construct(array|string $formats = [], ?string $message = null, ?array $groups = null, $payload = null, ?array $options = null)
7070
{

src/Symfony/Component/Validator/Constraints/DateTime.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class DateTime extends Constraint
3737
public string $message = 'This value is not a valid datetime.';
3838

3939
/**
40-
* @param string|array<string,mixed>|null $format The datetime format to match (defaults to 'Y-m-d H:i:s')
41-
* @param string[]|null $groups
42-
* @param array<string,mixed> $options
40+
* @param non-empty-string|array<string,mixed>|null $format The datetime format to match (defaults to 'Y-m-d H:i:s')
41+
* @param string[]|null $groups
42+
* @param array<string,mixed> $options
4343
*/
4444
public function __construct(string|array|null $format = null, ?string $message = null, ?array $groups = null, mixed $payload = null, array $options = [])
4545
{

src/Symfony/Component/Validator/Constraints/Expression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Expression extends Constraint
4343
* @param array<string,mixed>|null $values The values of the custom variables used in the expression (defaults to an empty array)
4444
* @param string[]|null $groups
4545
* @param array<string,mixed> $options
46-
* @param bool|null $negate Whether to fail is the expression evaluates to true (defaults to false)
46+
* @param bool|null $negate Whether to fail if the expression evaluates to true (defaults to false)
4747
*/
4848
public function __construct(
4949
string|ExpressionObject|array|null $expression,

src/Symfony/Component/Validator/Constraints/ExpressionSyntax.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ExpressionSyntax extends Constraint
3333

3434
/**
3535
* @param array<string,mixed>|null $options
36-
* @param string|null $service The service used to validate the constraint instead of the default one
36+
* @param non-empty-string|null $service The service used to validate the constraint instead of the default one
3737
* @param string[]|null $allowedVariables Restrict the available variables in the expression to these values (defaults to null that allows any variable)
3838
* @param string[]|null $groups
3939
*/

src/Symfony/Component/Validator/Constraints/File.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ class File extends Constraint
7373

7474
/**
7575
* @param array<string,mixed>|null $options
76-
* @param int|string|null $maxSize The max size of the underlying file
76+
* @param positive-int|string|null $maxSize The max size of the underlying file
7777
* @param bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null)
7878
* @param string[]|string|null $mimeTypes Acceptable media type(s). Prefer the extensions option that also enforce the file's extension consistency.
79-
* @param int|null $filenameMaxLength Maximum length of the file name
79+
* @param positive-int|null $filenameMaxLength Maximum length of the file name
8080
* @param string|null $disallowEmptyMessage Enable empty upload validation with this message in case of error
8181
* @param string|null $uploadIniSizeErrorMessage Message if the file size exceeds the max size configured in php.ini
8282
* @param string|null $uploadFormSizeErrorMessage Message if the file size exceeds the max size configured in the HTML input field

src/Symfony/Component/Validator/Constraints/Image.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ class Image extends File
9090

9191
/**
9292
* @param array<string,mixed>|null $options
93-
* @param int|string|null $maxSize The max size of the underlying file
93+
* @param positive-int|string|null $maxSize The max size of the underlying file
9494
* @param bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null)
95-
* @param string[]|null $mimeTypes Acceptable media types
96-
* @param int|null $filenameMaxLength Maximum length of the file name
95+
* @param non-empty-string[]|null $mimeTypes Acceptable media types
96+
* @param positive-int|null $filenameMaxLength Maximum length of the file name
9797
* @param string|null $disallowEmptyMessage Enable empty upload validation with this message in case of error
9898
* @param string|null $uploadIniSizeErrorMessage Message if the file size exceeds the max size configured in php.ini
9999
* @param string|null $uploadFormSizeErrorMessage Message if the file size exceeds the max size configured in the HTML input field
@@ -102,14 +102,14 @@ class Image extends File
102102
* @param string|null $uploadCantWriteErrorMessage Message if the uploaded file can not be stored in the temporary directory
103103
* @param string|null $uploadErrorMessage Message if an unknown error occurred on upload
104104
* @param string[]|null $groups
105-
* @param int|null $minWidth Minimum image width
106-
* @param int|null $maxWidth Maximum image width
107-
* @param int|null $maxHeight Maximum image height
108-
* @param int|null $minHeight Minimum image weight
109-
* @param int|float|null $maxRatio Maximum image ratio
110-
* @param int|float|null $minRatio Minimum image ration
111-
* @param int|float|null $minPixels Minimum amount of pixels
112-
* @param int|float|null $maxPixels Maximum amount of pixels
105+
* @param int<0, int>|null $minWidth Minimum image width
106+
* @param positive-int|null $maxWidth Maximum image width
107+
* @param positive-int|null $maxHeight Maximum image height
108+
* @param int<0, int>|null $minHeight Minimum image weight
109+
* @param positive-int|float|null $maxRatio Maximum image ratio
110+
* @param int<0, max>|float|null $minRatio Minimum image ration
111+
* @param int<0, max>|float|null $minPixels Minimum amount of pixels
112+
* @param positive-int|float|null $maxPixels Maximum amount of pixels
113113
* @param bool|null $allowSquare Whether to allow a square image (defaults to true)
114114
* @param bool|null $allowLandscape Whether to allow a landscape image (defaults to true)
115115
* @param bool|null $allowPortrait Whether to allow a portrait image (defaults to true)

0 commit comments

Comments
 (0)