-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] [WIP] remove support for generic constraint option handling #61063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.0
Are you sure you want to change the base?
Conversation
b8ba9e7
to
0c03730
Compare
@@ -32,26 +32,9 @@ class Callback extends Constraint | |||
* @param string[]|null $groups | |||
*/ | |||
#[HasNamedArguments] | |||
public function __construct(array|string|callable|null $callback = null, ?array $groups = null, mixed $payload = null, ?array $options = null) | |||
public function __construct(array|string|callable|null $callback = null, ?array $groups = null, mixed $payload = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array
and null
should be removed from the type (and the default value as well)
} | ||
|
||
parent::__construct($options, $groups, $payload); | ||
parent::__construct(null, $groups, $payload); | ||
|
||
$this->callback = $callback ?? $this->callback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be simplified as $this->callback = $callback
instead, as it won't be assigned by the parent constructor anymore
@@ -53,21 +53,9 @@ class CardScheme extends Constraint | |||
* @param array<string,mixed>|null $options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this phpdoc should also be removed
@@ -53,21 +53,9 @@ class CardScheme extends Constraint | |||
* @param array<string,mixed>|null $options | |||
*/ | |||
#[HasNamedArguments] | |||
public function __construct(array|string|null $schemes, ?string $message = null, ?array $groups = null, mixed $payload = null, ?array $options = null) | |||
public function __construct(array|string|null $schemes, ?string $message = null, ?array $groups = null, mixed $payload = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array<string,mixed>
should be removed from the phpdoc type of $schemes
, as that's the part referring to passing options as a positional argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same in most classes (with the appropriate name for the first argument of course)
@@ -32,7 +32,7 @@ public function __construct(mixed $options = null, ?array $groups = null, mixed | |||
throw new ConstraintDefinitionException(\sprintf('You can\'t redefine the "%s" option. Use the "%s::getConstraints()" method instead.', $this->getCompositeOption(), __CLASS__)); | |||
} | |||
|
|||
$this->constraints = $this->getConstraints($this->normalizeOptions($options)); | |||
$this->constraints = $this->getConstraints($options ?? []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to deprecate using options in this Compound abstract class first, to be able to remove support properly.
public function getDefaultOption(): ?string | ||
{ | ||
return 'constraints'; | ||
parent::__construct(null, $groups, $payload); | ||
} | ||
|
||
protected function getCompositeOption(): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method should also be removed, as it does not make sense anymore once the parent does not handle an array of options anymore.
} | ||
|
||
parent::__construct($options, $groups, $payload); | ||
parent::__construct(null, $groups, $payload); | ||
|
||
$this->minScore = $minScore ?? $this->minScore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->minScore = $minScore ?? $this->minScore; | |
$this->minScore = $minScore; |
5428b30
to
e934b07
Compare
924d748
to
7d0f7f6
Compare
7d0f7f6
to
f4c40e1
Compare
opening the PR already even if some polishing needs to be done (and not all tests pass yet) to avoid someone else wasting their time on this topic