mirror of
https://github.com/Respect/Validation.git
synced 2024-06-01 13:22:24 +02:00
Apply "SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
454096c459
commit
81a77ae125
|
@ -47,7 +47,7 @@ abstract class AbstractAge extends AbstractRule
|
|||
/**
|
||||
* Initializes the rule.
|
||||
*/
|
||||
public function __construct(int $age, string $format = null)
|
||||
public function __construct(int $age, ?string $format = null)
|
||||
{
|
||||
$this->age = $age;
|
||||
$this->format = $format;
|
||||
|
|
|
@ -56,7 +56,7 @@ abstract class AbstractRelated extends AbstractRule
|
|||
/**
|
||||
* @param mixed $reference
|
||||
*/
|
||||
public function __construct($reference, Validatable $validator = null, bool $mandatory = true)
|
||||
public function __construct($reference, ?Validatable $validator = null, bool $mandatory = true)
|
||||
{
|
||||
if (is_scalar($reference)) {
|
||||
$this->setName((string) $reference);
|
||||
|
|
|
@ -26,7 +26,7 @@ use Respect\Validation\Validatable;
|
|||
*/
|
||||
final class Attribute extends AbstractRelated
|
||||
{
|
||||
public function __construct(string $reference, Validatable $validator = null, bool $mandatory = true)
|
||||
public function __construct(string $reference, ?Validatable $validator = null, bool $mandatory = true)
|
||||
{
|
||||
parent::__construct($reference, $validator, $mandatory);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class Base extends AbstractRule
|
|||
/**
|
||||
* Initializes the Base rule.
|
||||
*/
|
||||
public function __construct(int $base, string $chars = null)
|
||||
public function __construct(int $base, ?string $chars = null)
|
||||
{
|
||||
if (!is_null($chars)) {
|
||||
$this->chars = $chars;
|
||||
|
|
|
@ -40,7 +40,7 @@ final class DateTime extends AbstractRule
|
|||
/**
|
||||
* Initializes the rule.
|
||||
*/
|
||||
public function __construct(string $format = null)
|
||||
public function __construct(?string $format = null)
|
||||
{
|
||||
$this->format = $format;
|
||||
$this->sample = date($format ?: 'c', strtotime('2005-12-30 01:02:03'));
|
||||
|
|
|
@ -40,7 +40,7 @@ final class Email extends AbstractRule
|
|||
*
|
||||
* If the EmailValidator instance is not defined, tries to create one.
|
||||
*/
|
||||
public function __construct(EmailValidator $validator = null)
|
||||
public function __construct(?EmailValidator $validator = null)
|
||||
{
|
||||
$this->validator = $validator ?: $this->createEmailValidator();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ final class Image extends AbstractRule
|
|||
/**
|
||||
* Initializes the rule.
|
||||
*/
|
||||
public function __construct(finfo $fileInfo = null)
|
||||
public function __construct(?finfo $fileInfo = null)
|
||||
{
|
||||
$this->fileInfo = $fileInfo ?: new finfo(FILEINFO_MIME_TYPE);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ final class Ip extends AbstractRule
|
|||
*
|
||||
* @throws ComponentException In case the range is invalid
|
||||
*/
|
||||
public function __construct(string $range = '*', int $options = null)
|
||||
public function __construct(string $range = '*', ?int $options = null)
|
||||
{
|
||||
$this->parseRange($range);
|
||||
$this->range = $this->createRange();
|
||||
|
|
|
@ -26,7 +26,7 @@ class Key extends AbstractRelated
|
|||
/**
|
||||
* @param mixed $reference
|
||||
*/
|
||||
public function __construct($reference, Validatable $referenceValidator = null, bool $mandatory = true)
|
||||
public function __construct($reference, ?Validatable $referenceValidator = null, bool $mandatory = true)
|
||||
{
|
||||
if (!is_scalar($reference) || $reference === '') {
|
||||
throw new ComponentException('Invalid array key name');
|
||||
|
|
|
@ -56,7 +56,7 @@ final class Length extends AbstractRule
|
|||
*
|
||||
* @throws ComponentException
|
||||
*/
|
||||
public function __construct(int $min = null, int $max = null, bool $inclusive = true)
|
||||
public function __construct(?int $min = null, ?int $max = null, bool $inclusive = true)
|
||||
{
|
||||
$this->minValue = $min;
|
||||
$this->maxValue = $max;
|
||||
|
|
|
@ -40,7 +40,7 @@ final class Mimetype extends AbstractRule
|
|||
/**
|
||||
* Initializes the rule by defining the expected mimetype from the input.
|
||||
*/
|
||||
public function __construct(string $mimetype, finfo $fileInfo = null)
|
||||
public function __construct(string $mimetype, ?finfo $fileInfo = null)
|
||||
{
|
||||
$this->mimetype = $mimetype;
|
||||
$this->fileInfo = $fileInfo ?: new finfo();
|
||||
|
|
|
@ -193,7 +193,7 @@ class PostalCode extends AbstractEnvelope
|
|||
];
|
||||
// phpcs:enable Generic.Files.LineLength.TooLong
|
||||
|
||||
public function __construct(string $countryCode, CountryCode $countryCodeRule = null)
|
||||
public function __construct(string $countryCode, ?CountryCode $countryCodeRule = null)
|
||||
{
|
||||
$countryCodeRule = $countryCodeRule ?: new CountryCode();
|
||||
if (!$countryCodeRule->validate($countryCode)) {
|
||||
|
|
|
@ -45,7 +45,7 @@ final class Sf extends AbstractRule
|
|||
*
|
||||
* In the the Validator is not defined, tries to create one.
|
||||
*/
|
||||
public function __construct(Constraint $constraint, ValidatorInterface $validator = null)
|
||||
public function __construct(Constraint $constraint, ?ValidatorInterface $validator = null)
|
||||
{
|
||||
$this->constraint = $constraint;
|
||||
$this->validator = $validator ?: Validation::createValidator();
|
||||
|
|
|
@ -29,7 +29,7 @@ class Sorted extends AbstractRule
|
|||
*/
|
||||
public $ascending = true;
|
||||
|
||||
public function __construct(callable $fn = null, bool $ascending = true)
|
||||
public function __construct(?callable $fn = null, bool $ascending = true)
|
||||
{
|
||||
$this->fn = $fn ?? static function ($x) {
|
||||
return $x;
|
||||
|
|
|
@ -46,7 +46,7 @@ final class Uuid extends AbstractRule
|
|||
*
|
||||
* @throws ComponentException when the version is not valid
|
||||
*/
|
||||
public function __construct(int $version = null)
|
||||
public function __construct(?int $version = null)
|
||||
{
|
||||
if ($version !== null && !$this->isSupportedVersion($version)) {
|
||||
throw new ComponentException(sprintf('Only versions 1, 3, 4, and 5 are supported: %d given', $version));
|
||||
|
|
|
@ -48,7 +48,7 @@ final class VideoUrl extends AbstractRule
|
|||
*
|
||||
* @throws ComponentException when the given service is not supported
|
||||
*/
|
||||
public function __construct(string $service = null)
|
||||
public function __construct(?string $service = null)
|
||||
{
|
||||
if ($service !== null && !$this->isSupportedService($service)) {
|
||||
throw new ComponentException(sprintf('"%s" is not a recognized video service.', $service));
|
||||
|
|
|
@ -41,7 +41,7 @@ final class When extends AbstractRule
|
|||
*/
|
||||
private $else;
|
||||
|
||||
public function __construct(Validatable $when, Validatable $then, Validatable $else = null)
|
||||
public function __construct(Validatable $when, Validatable $then, ?Validatable $else = null)
|
||||
{
|
||||
$this->when = $when;
|
||||
$this->then = $then;
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
<property name="spacesCountAroundEqualsSign" value="0" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
|
||||
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
|
||||
<properties>
|
||||
<property name="allAnnotationsAreUseful" value="true" />
|
||||
|
|
Loading…
Reference in a new issue