Skip to content

[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

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jul 8, 2025

Q A
Branch? 8.0
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

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

@carsonbot carsonbot added this to the 8.0 milestone Jul 8, 2025
@carsonbot carsonbot changed the title [WIP][Validator] remove support for generic constraint option handling [Validator] [WIP] remove support for generic constraint option handling Jul 8, 2025
@xabbuh xabbuh force-pushed the validator-cleanup branch from 95fd8a0 to d04270c Compare July 8, 2025 06:58
@xabbuh xabbuh requested a review from chalasr as a code owner July 8, 2025 06:58
@xabbuh xabbuh force-pushed the validator-cleanup branch 2 times, most recently from b8ba9e7 to 0c03730 Compare July 8, 2025 09:25
@@ -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)
Copy link
Member

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;
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

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 ?? []);
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->minScore = $minScore ?? $this->minScore;
$this->minScore = $minScore;

@xabbuh xabbuh force-pushed the validator-cleanup branch 2 times, most recently from 5428b30 to e934b07 Compare July 11, 2025 18:34
@alexandre-daubois alexandre-daubois added the BC Layer removal Used to track BC layer removals before a major release label Jul 11, 2025
@xabbuh xabbuh force-pushed the validator-cleanup branch 2 times, most recently from 924d748 to 7d0f7f6 Compare July 11, 2025 19:30
@xabbuh xabbuh force-pushed the validator-cleanup branch from 7d0f7f6 to f4c40e1 Compare July 12, 2025 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC Layer removal Used to track BC layer removals before a major release Feature Status: Needs Review Validator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy