We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 10 | class Sf extends AbstractRule |
||
| 11 | { |
||
| 12 | const SYMFONY_CONSTRAINT_NAMESPACE = 'Symfony\Component\Validator\Constraints\%s'; |
||
| 13 | public $name; |
||
| 14 | private $constraint; |
||
| 15 | |||
| 16 | 4 | public function __construct($name, $params = array()) |
|
| 17 | { |
||
| 18 | 4 | $this->name = ucfirst($name); |
|
| 19 | 4 | $this->constraint = $this->createSymfonyConstraint($this->name, $params); |
|
| 20 | 3 | } |
|
| 21 | |||
| 22 | 4 | private function createSymfonyConstraint($constraintName, $constraintConstructorParameters = array()) |
|
| 23 | { |
||
| 24 | 4 | $fullClassName = sprintf(self::SYMFONY_CONSTRAINT_NAMESPACE, $constraintName); |
|
| 25 | try { |
||
| 26 | 4 | $constraintReflection = new ReflectionClass($fullClassName); |
|
| 27 | 4 | } catch (ReflectionException $previousException) { |
|
| 28 | 1 | $baseExceptionMessage = 'Symfony/Validator constraint "%s" does not exist.'; |
|
| 29 | 1 | $exceptionMessage = sprintf($baseExceptionMessage, $constraintName); |
|
| 30 | 1 | throw new ComponentException($exceptionMessage, 0, $previousException); |
|
| 31 | } |
||
| 32 | 3 | if ($constraintReflection->hasMethod('__construct')) { |
|
| 33 | 3 | return $constraintReflection->newInstanceArgs($constraintConstructorParameters); |
|
| 34 | } |
||
| 35 | |||
| 36 | return $constraintReflection->newInstance(); |
||
| 37 | } |
||
| 38 | |||
| 39 | 3 | private function returnViolationsForConstraint($valueToValidate, Constraint $symfonyConstraint) |
|
| 45 | |||
| 46 | 2 | public function assert($input) |
|
| 47 | { |
||
| 55 | |||
| 56 | 1 | public function validate($input) |
|
| 65 | } |
||
| 66 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: