Apply "SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-02-09 13:42:51 +01:00
parent 454096c459
commit 81a77ae125
No known key found for this signature in database
GPG key ID: 221E9281655813A6
18 changed files with 18 additions and 17 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);
}

View file

@ -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;

View file

@ -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'));

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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();

View file

@ -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');

View file

@ -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;

View file

@ -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();

View file

@ -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)) {

View file

@ -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();

View file

@ -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;

View file

@ -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));

View file

@ -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));

View file

@ -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;

View file

@ -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" />