Skip to content

Commit f85a775

Browse files
Replace more docblocks by type-hints
1 parent 552d167 commit f85a775

17 files changed

+21
-38
lines changed

ConstraintViolation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ConstraintViolation implements ConstraintViolationInterface
4949
* caused the violation
5050
* @param mixed $cause The cause of the violation
5151
*/
52-
public function __construct($message, $messageTemplate, array $parameters, $root, $propertyPath, $invalidValue, $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;

Constraints/EmailValidator.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ class EmailValidator extends ConstraintValidator
2525
{
2626
private $isStrict;
2727

28-
/**
29-
* @param bool $strict
30-
*/
31-
public function __construct($strict = false)
28+
public function __construct(bool $strict = false)
3229
{
3330
$this->isStrict = $strict;
3431
}
@@ -111,24 +108,16 @@ public function validate($value, Constraint $constraint)
111108

112109
/**
113110
* Check DNS Records for MX type.
114-
*
115-
* @param string $host Host
116-
*
117-
* @return bool
118111
*/
119-
private function checkMX($host)
112+
private function checkMX(string $host): bool
120113
{
121114
return '' !== $host && checkdnsrr($host, 'MX');
122115
}
123116

124117
/**
125118
* Check if one of MX, A or AAAA DNS RR exists.
126-
*
127-
* @param string $host Host
128-
*
129-
* @return bool
130119
*/
131-
private function checkHost($host)
120+
private function checkHost(string $host): bool
132121
{
133122
return '' !== $host && ($this->checkMX($host) || (checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA')));
134123
}

Constraints/File.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class File extends Constraint
5959

6060
protected $maxSize;
6161

62+
/**
63+
* {@inheritdoc}
64+
*/
6265
public function __construct($options = null)
6366
{
6467
parent::__construct($options);

Context/ExecutionContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class ExecutionContext implements ExecutionContextInterface
140140
* @internal Called by {@link ExecutionContextFactory}. Should not be used
141141
* in user code.
142142
*/
143-
public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, $translationDomain = null)
143+
public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, string $translationDomain = null)
144144
{
145145
$this->validator = $validator;
146146
$this->root = $root;

Context/ExecutionContextFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ExecutionContextFactory implements ExecutionContextFactoryInterface
3434
* use for translating
3535
* violation messages
3636
*/
37-
public function __construct(TranslatorInterface $translator, $translationDomain = null)
37+
public function __construct(TranslatorInterface $translator, string $translationDomain = null)
3838
{
3939
$this->translator = $translator;
4040
$this->translationDomain = $translationDomain;

DependencyInjection/AddConstraintValidatorsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AddConstraintValidatorsPass implements CompilerPassInterface
2525
private $validatorFactoryServiceId;
2626
private $constraintValidatorTag;
2727

28-
public function __construct($validatorFactoryServiceId = 'validator.validator_factory', $constraintValidatorTag = 'validator.constraint_validator')
28+
public function __construct(string $validatorFactoryServiceId = 'validator.validator_factory', string $constraintValidatorTag = 'validator.constraint_validator')
2929
{
3030
$this->validatorFactoryServiceId = $validatorFactoryServiceId;
3131
$this->constraintValidatorTag = $constraintValidatorTag;

DependencyInjection/AddValidatorInitializersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AddValidatorInitializersPass implements CompilerPassInterface
2424
private $builderService;
2525
private $initializerTag;
2626

27-
public function __construct($builderService = 'validator.builder', $initializerTag = 'validator.initializer')
27+
public function __construct(string $builderService = 'validator.builder', string $initializerTag = 'validator.initializer')
2828
{
2929
$this->builderService = $builderService;
3030
$this->initializerTag = $initializerTag;

Exception/InvalidOptionsException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class InvalidOptionsException extends ValidatorException
1515
{
1616
private $options;
1717

18-
public function __construct($message, array $options)
18+
public function __construct(string $message, array $options)
1919
{
2020
parent::__construct($message);
2121

Exception/MissingOptionsException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MissingOptionsException extends ValidatorException
1515
{
1616
private $options;
1717

18-
public function __construct($message, array $options)
18+
public function __construct(string $message, array $options)
1919
{
2020
parent::__construct($message);
2121

Exception/UnexpectedTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class UnexpectedTypeException extends ValidatorException
1515
{
16-
public function __construct($value, $expectedType)
16+
public function __construct($value, string $expectedType)
1717
{
1818
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value)));
1919
}

0 commit comments

Comments
 (0)