Skip to content

Commit 59a184b

Browse files
committed
[Form] add missing deprecation triggers
Passing implementations of the pre 2.5 validator API to the constructors of the `ValidatorExtension` and the `ValidationListener` must trigger a deprecation.
1 parent 52c1f47 commit 59a184b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Extension/Validator/EventListener/ValidationListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function __construct($validator, ViolationMapperInterface $violationMappe
4646
throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface');
4747
}
4848

49+
if ($validator instanceof LegacyValidatorInterface) {
50+
@trigger_error('Passing an instance of Symfony\Component\Validator\ValidatorInterface as argument to the '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use an implementation of Symfony\Component\Validator\Validator\ValidatorInterface instead', E_USER_DEPRECATED);
51+
}
52+
4953
$this->validator = $validator;
5054
$this->violationMapper = $violationMapper;
5155
}

Extension/Validator/ValidatorExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function __construct($validator)
4040
$metadata = $validator->getMetadataFor('Symfony\Component\Form\Form');
4141
// 2.4 API
4242
} elseif ($validator instanceof LegacyValidatorInterface) {
43+
@trigger_error('Passing an instance of Symfony\Component\Validator\ValidatorInterface as argument to the '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use an implementation of Symfony\Component\Validator\Validator\ValidatorInterface instead', E_USER_DEPRECATED);
4344
$metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\Component\Form\Form');
4445
} else {
4546
throw new UnexpectedTypeException($validator, 'Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface');

0 commit comments

Comments
 (0)