Skip to content

Commit e88263c

Browse files
bug #61056 [Validator] Allow mixed root on CompoundConstraintTestCase validator (thePanz)
This PR was merged into the 7.2 branch. Discussion ---------- [Validator] Allow mixed root on `CompoundConstraintTestCase` validator | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT The CompoundConstraintTestCase is currently defining a `protected string $root`, forcing the root to be a "string". Testing compound constraints where the root is something different is triggering Static-Analysis (phpstan) warings or (worst) casting the `$root` to a string, causing PHP errors. In the given code: the `$root` is passed to the ExecutionContext, which has the following constructor signature: `__construct(private ValidatorInterface $validator, private mixed $root, private TranslatorInterface $translator, ...)`, thus `mixed` can be safely used in the `CompoundConstraintTestCase` class too. Commits ------- 47b5387 Allow mixed root on CompoundConstraintTestCase validator
2 parents 558477c + 47b5387 commit e88263c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Validator/Test/CompoundConstraintTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class CompoundConstraintTestCase extends TestCase
3535
protected ValidatorInterface $validator;
3636
protected ?ConstraintViolationListInterface $violationList = null;
3737
protected ExecutionContextInterface $context;
38-
protected string $root;
38+
protected mixed $root;
3939

4040
private mixed $validatedValue;
4141

0 commit comments

Comments
 (0)