These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the Liip/FunctionalTestBundle |
||
| 5 | * |
||
| 6 | * (c) Lukas Kahwe Smith <[email protected]> |
||
| 7 | * |
||
| 8 | * This source file is subject to the MIT license that is bundled |
||
| 9 | * with this source code in the file LICENSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Liip\FunctionalTestBundle\Validator; |
||
| 13 | |||
| 14 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
| 15 | use Symfony\Component\HttpKernel\KernelEvents; |
||
| 16 | use Symfony\Component\Validator\ConstraintViolationList; |
||
| 17 | use Symfony\Component\Validator\ConstraintViolationListInterface; |
||
| 18 | use Symfony\Component\Validator\Context\ExecutionContextInterface; |
||
| 19 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
||
| 20 | |||
| 21 | class DataCollectingValidator implements ValidatorInterface, EventSubscriberInterface |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @var ValidatorInterface |
||
| 25 | */ |
||
| 26 | protected $wrappedValidator; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @var ConstraintViolationListInterface |
||
| 30 | */ |
||
| 31 | protected $lastErrors; |
||
| 32 | |||
| 33 | 18 | public function __construct(ValidatorInterface $wrappedValidator) |
|
| 34 | { |
||
| 35 | 18 | $this->wrappedValidator = $wrappedValidator; |
|
| 36 | 18 | $this->clearLastErrors(); |
|
| 37 | 18 | } |
|
| 38 | |||
| 39 | 18 | public function clearLastErrors() |
|
| 40 | { |
||
| 41 | 18 | $this->lastErrors = new ConstraintViolationList(); |
|
|
0 ignored issues
–
show
|
|||
| 42 | 18 | } |
|
| 43 | |||
| 44 | 4 | public function getLastErrors() |
|
| 45 | { |
||
| 46 | 4 | return $this->lastErrors; |
|
| 47 | } |
||
| 48 | |||
| 49 | public function getMetadataFor($value) |
||
| 50 | { |
||
| 51 | return $this->wrappedValidator->getMetadataFor($value); |
||
| 52 | } |
||
| 53 | |||
| 54 | public function hasMetadataFor($value) |
||
| 55 | { |
||
| 56 | return $this->wrappedValidator->hasMetadataFor($value); |
||
| 57 | } |
||
| 58 | |||
| 59 | 3 | public function validate($value, $constraints = null, $groups = null) |
|
| 60 | { |
||
| 61 | 3 | return $this->lastErrors = $this->wrappedValidator->validate($value, $constraints, $groups); |
|
| 62 | } |
||
| 63 | |||
| 64 | public function validateProperty($object, $propertyName, $groups = null) |
||
| 65 | { |
||
| 66 | return $this->wrappedValidator->validateProperty($object, $propertyName, $groups); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) |
||
| 70 | { |
||
| 71 | return $this->wrappedValidator->validatePropertyValue($objectOrClass, $propertyName, $value, $groups); |
||
| 72 | } |
||
| 73 | |||
| 74 | public function startContext() |
||
| 75 | { |
||
| 76 | return $this->wrappedValidator->startContext(); |
||
| 77 | } |
||
| 78 | |||
| 79 | public function inContext(ExecutionContextInterface $context) |
||
| 80 | { |
||
| 81 | return $this->wrappedValidator->inContext($context); |
||
| 82 | } |
||
| 83 | |||
| 84 | 31 | public static function getSubscribedEvents() |
|
| 85 | { |
||
| 86 | return array( |
||
| 87 | 31 | KernelEvents::REQUEST => array('clearLastErrors', 99999), |
|
| 88 | 31 | ); |
|
| 89 | } |
||
| 90 | } |
||
| 91 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..