The following error occurs: Declaration of TelephoneConstraintValidator::initialize() must be compatible with ConstraintValidatorInterface::initialize(Symfony\Component\Validator\Context\ExecutionContextInterface $context) in TelephoneConstraintValidator.php on line 12
The class defines the following use statement:
use Symfony\Component\Validator\ExecutionContextInterface;
However the interface defines:
use Symfony\Component\Validator\Context\ExecutionContextInterface;
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | invalid_use_statement-2907271-7.patch | 2 KB | zaporylie |
| #2 | telephone_validation_fix_import_2907271_2_d8.patch | 702 bytes | mpp |
Comments
Comment #2
mpp commentedComment #3
zaporylieWhich version of symfony/validator are you using? Which version of Drupal core? For symfony/validator:2.8
ConstraintValidatorInterface::initialize($context)expects$contextto be typeof\Symfony\Component\Validator\ExecutionContextInterfaceComment #4
mpp commentedI'm using Drupal 8.4 (rc1) and indeed with that Symfony got upgraded from 2.4 to 3.2:
Comment #5
zaporylieFrom 2.4? I thought 2.7 was requirement for 8.0.0.
I think maybe it's better to extend abstract Symfony\Component\Validator\ConstraintValidator than directly implement ConstraintValidatorInterface which should provide BC layer.
http://api.symfony.com/2.7/Symfony/Component/Validator/ConstraintValidat...
http://api.symfony.com/3.2/Symfony/Component/Validator/ConstraintValidat...
Comment #6
zaporyliePatch #2 makes module incompatible with D8.3 so changing status to Needs work.
Fatal error: Declaration of Drupal\telephone_validation\Plugin\Validation\Constraint\TelephoneConstraintValidator::initialize(Symfony\Component\Validator\Context\ExecutionContextInterface $context) must be compatible with Symfony\Component\Validator\ConstraintValidatorInterface::initialize(Symfony\Component\Validator\ExecutionContextInterface $context)Comment #7
zaporylieI thought about something like this. What do you think @mpp?
Comment #8
zaporylieAdded Kernel test in #2907589: Create basic Kernel test to prove ValidtaionConstraint work which should catch Exceptions in TelephoneConstrainValidator. Requeued tests in #2 and #7
Comment #9
zaporylieTests are done. It was proven that #2 breaks BC and #7 works ok.
Leaving issue open for a day or two waiting for a comment/review.
Comment #11
zaporylieCommitted and pushed to 8.x-2.x. Thanks!