Skip to content

Commit

Permalink
Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_…
Browse files Browse the repository at this point in the history
…null_value
  • Loading branch information
nicolas-grekas committed Jan 23, 2024
1 parent d43b85b commit eaf3b4f
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Extractor/PhpDocExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
* @param string[]|null $accessorPrefixes
* @param string[]|null $arrayMutatorPrefixes
*/
public function __construct(DocBlockFactoryInterface $docBlockFactory = null, array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
public function __construct(?DocBlockFactoryInterface $docBlockFactory = null, ?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null)
{
if (!class_exists(DocBlockFactory::class)) {
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/reflection-docblock" package is not installed. Try running composer require "phpdocumentor/reflection-docblock".', __CLASS__));
Expand Down
2 changes: 1 addition & 1 deletion Extractor/PhpStanExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class PhpStanExtractor implements PropertyTypeExtractorInterface, Construc
* @param list<string>|null $accessorPrefixes
* @param list<string>|null $arrayMutatorPrefixes
*/
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null)
public function __construct(?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null)
{
if (!class_exists(ContextFactory::class)) {
throw new \LogicException(sprintf('Unable to use the "%s" class as the "phpdocumentor/type-resolver" package is not installed. Try running composer require "phpdocumentor/type-resolver".', __CLASS__));
Expand Down
2 changes: 1 addition & 1 deletion Extractor/ReflectionExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ReflectionExtractor implements PropertyListExtractorInterface, PropertyTyp
* @param string[]|null $accessorPrefixes
* @param string[]|null $arrayMutatorPrefixes
*/
public function __construct(array $mutatorPrefixes = null, array $accessorPrefixes = null, array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET)
public function __construct(?array $mutatorPrefixes = null, ?array $accessorPrefixes = null, ?array $arrayMutatorPrefixes = null, bool $enableConstructorExtraction = true, int $accessFlags = self::ALLOW_PUBLIC, ?InflectorInterface $inflector = null, int $magicMethodsFlags = self::ALLOW_MAGIC_GET | self::ALLOW_MAGIC_SET)
{
$this->mutatorPrefixes = $mutatorPrefixes ?? self::$defaultMutatorPrefixes;
$this->accessorPrefixes = $accessorPrefixes ?? self::$defaultAccessorPrefixes;
Expand Down
2 changes: 1 addition & 1 deletion PhpStan/NameScopeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
final class NameScopeFactory
{
public function create(string $calledClassName, string $declaringClassName = null): NameScope
public function create(string $calledClassName, ?string $declaringClassName = null): NameScope
{
$declaringClassName = $declaringClassName ?? $calledClassName;

Expand Down
2 changes: 1 addition & 1 deletion PropertyWriteInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class PropertyWriteInfo
private $removerInfo;
private $errors = [];

public function __construct(string $type = self::TYPE_NONE, string $name = null, string $visibility = null, bool $static = null)
public function __construct(string $type = self::TYPE_NONE, ?string $name = null, ?string $visibility = null, ?bool $static = null)
{
$this->type = $type;
$this->name = $name;
Expand Down
10 changes: 5 additions & 5 deletions Tests/Extractor/PhpDocExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function setUp(): void
/**
* @dataProvider typesProvider
*/
public function testExtract($property, array $type = null, $shortDescription, $longDescription)
public function testExtract($property, ?array $type = null, $shortDescription, $longDescription)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
$this->assertSame($shortDescription, $this->extractor->getShortDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testInvalid($property, $shortDescription, $longDescription)
/**
* @dataProvider typesWithNoPrefixesProvider
*/
public function testExtractTypesWithNoPrefixes($property, array $type = null)
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
{
$noPrefixExtractor = new PhpDocExtractor(null, [], [], []);

Expand Down Expand Up @@ -157,7 +157,7 @@ public static function typesProvider()
/**
* @dataProvider provideCollectionTypes
*/
public function testExtractCollection($property, array $type = null, $shortDescription, $longDescription)
public function testExtractCollection($property, ?array $type = null, $shortDescription, $longDescription)
{
if (!class_exists(Collection::class)) {
$this->markTestSkipped('Collections are not implemented in current phpdocumentor/type-resolver version');
Expand Down Expand Up @@ -223,7 +223,7 @@ public static function provideCollectionTypes()
/**
* @dataProvider typesWithCustomPrefixesProvider
*/
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
{
$customExtractor = new PhpDocExtractor(null, ['add', 'remove'], ['is', 'can']);

Expand Down Expand Up @@ -432,7 +432,7 @@ protected static function isPhpDocumentorV5()
/**
* @dataProvider constructorTypesProvider
*/
public function testExtractConstructorTypes($property, array $type = null)
public function testExtractConstructorTypes($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
}
Expand Down
10 changes: 5 additions & 5 deletions Tests/Extractor/PhpStanExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function setUp(): void
/**
* @dataProvider typesProvider
*/
public function testExtract($property, array $type = null)
public function testExtract($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}
Expand Down Expand Up @@ -80,7 +80,7 @@ public function testInvalid($property)
/**
* @dataProvider typesWithNoPrefixesProvider
*/
public function testExtractTypesWithNoPrefixes($property, array $type = null)
public function testExtractTypesWithNoPrefixes($property, ?array $type = null)
{
$noPrefixExtractor = new PhpStanExtractor([], [], []);

Expand Down Expand Up @@ -135,7 +135,7 @@ public static function typesProvider()
/**
* @dataProvider provideCollectionTypes
*/
public function testExtractCollection($property, array $type = null)
public function testExtractCollection($property, ?array $type = null)
{
$this->testExtract($property, $type);
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public static function provideCollectionTypes()
/**
* @dataProvider typesWithCustomPrefixesProvider
*/
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
public function testExtractTypesWithCustomPrefixes($property, ?array $type = null)
{
$customExtractor = new PhpStanExtractor(['add', 'remove'], ['is', 'can']);

Expand Down Expand Up @@ -349,7 +349,7 @@ public static function propertiesParentTypeProvider(): array
/**
* @dataProvider constructorTypesProvider
*/
public function testExtractConstructorTypes($property, array $type = null)
public function testExtractConstructorTypes($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
}
Expand Down
16 changes: 8 additions & 8 deletions Tests/Extractor/ReflectionExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function testGetPropertiesWithNoPrefixes()
/**
* @dataProvider typesProvider
*/
public function testExtractors($property, array $type = null)
public function testExtractors($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property, []));
}
Expand All @@ -235,7 +235,7 @@ public static function typesProvider()
/**
* @dataProvider php7TypesProvider
*/
public function testExtractPhp7Type(string $class, string $property, array $type = null)
public function testExtractPhp7Type(string $class, string $property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes($class, $property, []));
}
Expand All @@ -256,7 +256,7 @@ public static function php7TypesProvider()
/**
* @dataProvider php71TypesProvider
*/
public function testExtractPhp71Type($property, array $type = null)
public function testExtractPhp71Type($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php71Dummy', $property, []));
}
Expand All @@ -277,7 +277,7 @@ public static function php71TypesProvider()
*
* @requires PHP 8
*/
public function testExtractPhp80Type($property, array $type = null)
public function testExtractPhp80Type($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php80Dummy', $property, []));
}
Expand All @@ -301,7 +301,7 @@ public static function php80TypesProvider()
*
* @requires PHP 8.1
*/
public function testExtractPhp81Type($property, array $type = null)
public function testExtractPhp81Type($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php81Dummy', $property, []));
}
Expand All @@ -327,7 +327,7 @@ public function testReadonlyPropertiesAreNotWriteable()
*
* @requires PHP 8.2
*/
public function testExtractPhp82Type($property, array $type = null)
public function testExtractPhp82Type($property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php82Dummy', $property, []));
}
Expand Down Expand Up @@ -472,7 +472,7 @@ public static function getInitializableProperties(): array
/**
* @dataProvider constructorTypesProvider
*/
public function testExtractTypeConstructor(string $class, string $property, array $type = null)
public function testExtractTypeConstructor(string $class, string $property, ?array $type = null)
{
/* Check that constructor extractions works by default, and if passed in via context.
Check that null is returned if constructor extraction is disabled */
Expand Down Expand Up @@ -663,7 +663,7 @@ public function testGetWriteInfoReadonlyProperties()
/**
* @dataProvider extractConstructorTypesProvider
*/
public function testExtractConstructorTypes(string $property, array $type = null)
public function testExtractConstructorTypes(string $property, ?array $type = null)
{
$this->assertEquals($type, $this->extractor->getTypesFromConstructor('Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy', $property));
}
Expand Down
2 changes: 1 addition & 1 deletion Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Type
*
* @throws \InvalidArgumentException
*/
public function __construct(string $builtinType, bool $nullable = false, string $class = null, bool $collection = false, $collectionKeyType = null, $collectionValueType = null)
public function __construct(string $builtinType, bool $nullable = false, ?string $class = null, bool $collection = false, $collectionKeyType = null, $collectionValueType = null)
{
if (!\in_array($builtinType, self::$builtinTypes)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid PHP type.', $builtinType));
Expand Down
2 changes: 1 addition & 1 deletion Util/PhpDocTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getTypes(DocType $varType): array
/**
* Creates a {@see Type} from a PHPDoc type.
*/
private function createType(DocType $type, bool $nullable, string $docType = null): ?Type
private function createType(DocType $type, bool $nullable, ?string $docType = null): ?Type
{
$docType = $docType ?? (string) $type;

Expand Down

0 comments on commit eaf3b4f

Please sign in to comment.