Skip to content

Commit b51ff61

Browse files
committed
Fine tune constructor types
1 parent 9ce9895 commit b51ff61

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ConstraintViolation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class ConstraintViolation implements ConstraintViolationInterface
4444
* violation
4545
* @param int|null $plural The number for determining the plural
4646
* form when translating the message
47-
* @param mixed $code The error code of the violation
47+
* @param string|null $code The error code of the violation
4848
* @param Constraint|null $constraint The constraint whose validation
4949
* caused the violation
5050
* @param mixed $cause The cause of the violation
5151
*/
52-
public function __construct(?string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
52+
public function __construct(string $message, ?string $messageTemplate, array $parameters, $root, ?string $propertyPath, $invalidValue, int $plural = null, $code = null, Constraint $constraint = null, $cause = null)
5353
{
5454
$this->message = $message;
5555
$this->messageTemplate = $messageTemplate;

Test/ConstraintValidatorTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ protected function restoreDefaultTimezone()
9999
protected function createContext()
100100
{
101101
$translator = $this->getMockBuilder(TranslatorInterface::class)->getMock();
102+
$translator->expects($this->any())->method('trans')->willReturnArgument(0);
102103
$validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
103104
$contextualValidator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ContextualValidatorInterface')->getMock();
104105

@@ -330,7 +331,7 @@ public function assertRaised()
330331
private function getViolation()
331332
{
332333
return new ConstraintViolation(
333-
null,
334+
$this->message,
334335
$this->message,
335336
$this->parameters,
336337
$this->context->getRoot(),

Violation/ConstraintViolationBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
4747
/**
4848
* @param TranslatorInterface $translator
4949
*/
50-
public function __construct(ConstraintViolationList $violations, Constraint $constraint, $message, array $parameters, $root, $propertyPath, $invalidValue, $translator, $translationDomain = null)
50+
public function __construct(ConstraintViolationList $violations, Constraint $constraint, string $message, array $parameters, $root, string $propertyPath, $invalidValue, $translator, string $translationDomain = null)
5151
{
5252
if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
5353
throw new \TypeError(sprintf('Argument 8 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));

0 commit comments

Comments
 (0)