Skip to content

Commit

Permalink
Configure "nullable_type_declaration_for_default_null_value" CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys authored and franmomu committed Jul 25, 2023
1 parent 94ef07a commit f21d888
Show file tree
Hide file tree
Showing 37 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
'no_superfluous_elseif' => true,
'no_unset_on_property' => true,
'no_useless_else' => true,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true],
'ordered_class_elements' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'phpdoc_summary' => false,
Expand Down
8 changes: 4 additions & 4 deletions src/DoctrineExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class DoctrineExtensions
* Hooks all extension metadata mapping drivers into
* the given driver chain of drivers for the ORM.
*/
public static function registerMappingIntoDriverChainORM(MappingDriverChain $driverChain, Reader $reader = null): void
public static function registerMappingIntoDriverChainORM(MappingDriverChain $driverChain, ?Reader $reader = null): void
{
if (!$reader) {
$reader = self::createAnnotationReader();
Expand All @@ -51,7 +51,7 @@ public static function registerMappingIntoDriverChainORM(MappingDriverChain $dri
* Hooks only superclass extension metadata mapping drivers into
* the given driver chain of drivers for the ORM.
*/
public static function registerAbstractMappingIntoDriverChainORM(MappingDriverChain $driverChain, Reader $reader = null): void
public static function registerAbstractMappingIntoDriverChainORM(MappingDriverChain $driverChain, ?Reader $reader = null): void
{
if (!$reader) {
$reader = self::createAnnotationReader();
Expand All @@ -68,7 +68,7 @@ public static function registerAbstractMappingIntoDriverChainORM(MappingDriverCh
* Hooks all extension metadata mapping drivers into
* the given driver chain of drivers for the MongoDB ODM.
*/
public static function registerMappingIntoDriverChainMongodbODM(MappingDriverChain $driverChain, Reader $reader = null): void
public static function registerMappingIntoDriverChainMongodbODM(MappingDriverChain $driverChain, ?Reader $reader = null): void
{
if (!$reader) {
$reader = self::createAnnotationReader();
Expand All @@ -84,7 +84,7 @@ public static function registerMappingIntoDriverChainMongodbODM(MappingDriverCha
* Hooks only superclass extension metadata mapping drivers into
* the given driver chain of drivers for the MongoDB ODM.
*/
public static function registerAbstractMappingIntoDriverChainMongodbODM(MappingDriverChain $driverChain, Reader $reader = null): void
public static function registerAbstractMappingIntoDriverChainMongodbODM(MappingDriverChain $driverChain, ?Reader $reader = null): void
{
if (!$reader) {
$reader = self::createAnnotationReader();
Expand Down
2 changes: 1 addition & 1 deletion src/SoftDeleteable/Traits/SoftDeleteable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait SoftDeleteable
*
* @return self
*/
public function setDeletedAt(DateTime $deletedAt = null)
public function setDeletedAt(?DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;

Expand Down
2 changes: 1 addition & 1 deletion src/SoftDeleteable/Traits/SoftDeleteableDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait SoftDeleteableDocument
*
* @return self
*/
public function setDeletedAt(DateTime $deletedAt = null)
public function setDeletedAt(?DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;

Expand Down
2 changes: 1 addition & 1 deletion src/SoftDeleteable/Traits/SoftDeleteableEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait SoftDeleteableEntity
*
* @return self
*/
public function setDeletedAt(DateTime $deletedAt = null)
public function setDeletedAt(?DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;

Expand Down
2 changes: 1 addition & 1 deletion src/Tool/Logging/DBAL/QueryAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(AbstractPlatform $platform)
/**
* @return void
*/
public function startQuery($sql, array $params = null, array $types = null)
public function startQuery($sql, ?array $params = null, ?array $types = null)
{
$this->queryStartTime = microtime(true);
$this->queries[] = $this->generateSql($sql, $params, $types);
Expand Down
2 changes: 1 addition & 1 deletion src/Tree/Traits/MaterializedPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait MaterializedPath
*
* @return self
*/
public function setParent(self $parent = null)
public function setParent(?self $parent = null)
{
$this->parent = $parent;

Expand Down
2 changes: 1 addition & 1 deletion src/Uploadable/UploadableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class UploadableListener extends MappedEventSubscriber
*/
private $fileInfoObjects = [];

public function __construct(MimeTypeGuesserInterface $mimeTypeGuesser = null)
public function __construct(?MimeTypeGuesserInterface $mimeTypeGuesser = null)
{
parent::__construct();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RelativeSlug
#[ODM\ReferenceOne(targetDocument: Article::class)]
private $article;

public function setArticle(Article $article = null): void
public function setArticle(?Article $article = null): void
{
$this->article = $article;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TreeSlug
#[ODM\ReferenceOne(targetDocument: self::class)]
private $parent;

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ArticleRelativeSlug
#[ORM\ManyToOne(targetEntity: Article::class)]
private $article;

public function setArticle(Article $article = null): void
public function setArticle(?Article $article = null): void
{
$this->article = $article;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function __construct()
$this->children = new ArrayCollection();
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Sluggable/Fixture/Handler/People/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Person
#[ORM\ManyToOne(targetEntity: Occupation::class)]
private $occupation;

public function setOccupation(Occupation $occupation = null): void
public function setOccupation(?Occupation $occupation = null): void
{
$this->occupation = $occupation;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Sluggable/Fixture/Handler/TreeSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function __construct()
$this->children = new ArrayCollection();
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function __construct()
$this->children = new ArrayCollection();
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Sluggable/Fixture/Handler/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class User
#[ORM\ManyToOne(targetEntity: Company::class)]
private $company;

public function setCompany(Company $company = null): void
public function setCompany(?Company $company = null): void
{
$this->company = $company;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Sortable/Fixture/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getPosition(): ?int
return $this->position;
}

public function setCategory(Category $category = null): void
public function setCategory(?Category $category = null): void
{
$this->category = $category;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Gedmo/Tool/BaseTestCaseMongoODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function getMockDocumentManager(?EventManager $evm = null, ?Configurat
return $this->dm = DocumentManager::create($client, $config, $evm);
}

protected function getDefaultDocumentManager(EventManager $evm = null): DocumentManager
protected function getDefaultDocumentManager(?EventManager $evm = null): DocumentManager
{
return $this->getMockDocumentManager($evm, $this->getDefaultConfiguration());
}
Expand All @@ -83,7 +83,7 @@ protected function getDefaultDocumentManager(EventManager $evm = null): Document
* DocumentManager mock object with
* annotation mapping driver
*/
protected function getMockMappedDocumentManager(EventManager $evm = null, Configuration $config = null): DocumentManager
protected function getMockMappedDocumentManager(?EventManager $evm = null, ?Configuration $config = null): DocumentManager
{
$conn = $this->createStub(Client::class);

Expand Down
8 changes: 4 additions & 4 deletions tests/Gedmo/Tool/BaseTestCaseOM.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function getORMDriver(array $paths = []): MappingDriver
* DocumentManager mock object together with
* annotation mapping driver and database
*/
protected function getMockDocumentManager(string $dbName, MappingDriver $mappingDriver = null): DocumentManager
protected function getMockDocumentManager(string $dbName, ?MappingDriver $mappingDriver = null): DocumentManager
{
if (!extension_loaded('mongodb')) {
static::markTestSkipped('Missing Mongo extension.');
Expand All @@ -110,7 +110,7 @@ protected function getMockDocumentManager(string $dbName, MappingDriver $mapping
* annotation mapping driver and pdo_sqlite
* database in memory
*/
protected function getDefaultMockSqliteEntityManager(array $fixtures, MappingDriver $mappingDriver = null): EntityManager
protected function getDefaultMockSqliteEntityManager(array $fixtures, ?MappingDriver $mappingDriver = null): EntityManager
{
$conn = [
'driver' => 'pdo_sqlite',
Expand Down Expand Up @@ -153,7 +153,7 @@ private function getEventManager(): EventManager
/**
* Get annotation mapping configuration
*/
private function getMockODMMongoDBConfig(string $dbName, MappingDriver $mappingDriver = null): Configuration
private function getMockODMMongoDBConfig(string $dbName, ?MappingDriver $mappingDriver = null): Configuration
{
if (null === $mappingDriver) {
$mappingDriver = $this->getMongoDBDriver();
Expand All @@ -176,7 +176,7 @@ private function getMockODMMongoDBConfig(string $dbName, MappingDriver $mappingD
/**
* Get annotation mapping configuration for ORM
*/
private function getMockORMConfig(MappingDriver $mappingDriver = null): \Doctrine\ORM\Configuration
private function getMockORMConfig(?MappingDriver $mappingDriver = null): \Doctrine\ORM\Configuration
{
$config = new \Doctrine\ORM\Configuration();
$config->setProxyDir(TESTS_TEMP_DIR);
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tool/BaseTestCaseORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function setUp(): void
* annotation mapping driver and pdo_sqlite
* database in memory
*/
protected function getDefaultMockSqliteEntityManager(EventManager $evm = null, Configuration $config = null): EntityManager
protected function getDefaultMockSqliteEntityManager(?EventManager $evm = null, ?Configuration $config = null): EntityManager
{
$conn = [
'driver' => 'pdo_sqlite',
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tool/QueryAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(AbstractPlatform $platform)
$this->platform = $platform;
}

public function startQuery($sql, array $params = null, array $types = null): void
public function startQuery($sql, ?array $params = null, ?array $types = null): void
{
$this->queries[] = $this->generateSql($sql, $params, $types);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Translator/Fixture/PersonCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getDescription(): ?string
/**
* @return self|CustomProxy
*/
public function translate(string $locale = null)
public function translate(?string $locale = null)
{
if (null === $locale) {
return $this;
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/ANode.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getId(): ?int
return $this->id;
}

public function setParent(BaseNode $parent = null): void
public function setParent(?BaseNode $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Closure/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Closure/CategoryWithoutLevel.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Closure/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getName(): ?string
return $this->name;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Document/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Document/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/ForeignRootCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/Issue2408/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function getRoot(): ?self
return $this->root;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/MPCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parentId = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/MPCategoryWithRootAssociation.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parentId = $parent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parentId = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/MPFeaturesCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parentId = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/RootAssociationCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/Fixture/RootCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function getTitle(): ?string
return $this->title;
}

public function setParent(self $parent = null): void
public function setParent(?self $parent = null): void
{
$this->parent = $parent;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Gedmo/Tree/MaterializedPathORMRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ protected function getUsedEntityFixtures(): array
/**
* @phpstan-param class-string|null $class
*/
private function populate(string $class = null): void
private function populate(?string $class = null): void
{
$root = $this->createCategory($class);
$root->setTitle('Food');
Expand Down

0 comments on commit f21d888

Please sign in to comment.