From ca85e0ce2993845c3e04fe48a6ca3a442b561ac4 Mon Sep 17 00:00:00 2001 From: Jakub Caban Date: Tue, 26 Jan 2021 14:28:39 +0100 Subject: [PATCH] Coding Standards --- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 12 ++++++------ tests/Doctrine/Tests/Models/CMS/CmsUserTyped.php | 2 ++ .../Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 1be414b3557..0c81de20b1d 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -1426,18 +1426,18 @@ protected function _validateAndCompleteFieldMapping(array &$mapping) && $this->reflClass->hasProperty($mapping['fieldName']) ) { $property = $this->reflClass->getProperty($mapping['fieldName']); - $type = $property->getType(); + $type = $property->getType(); if ($type) { - if (!isset($mapping['nullable'])) { + if (! isset($mapping['nullable'])) { $mapping['nullable'] = $type->allowsNull(); } if ( - !isset($mapping['type']) + ! isset($mapping['type']) && ($type instanceof ReflectionNamedType) ) { - switch($type->getName()) { + switch ($type->getName()) { case DateInterval::class: $mapping['type'] = 'dateinterval'; break; @@ -1570,7 +1570,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) && $this->reflClass->hasProperty($mapping['fieldName']) ) { $property = $this->reflClass->getProperty($mapping['fieldName']); - $type = $property->getType(); + $type = $property->getType(); if ( ! isset($mapping['targetEntity']) @@ -1582,7 +1582,7 @@ protected function _validateAndCompleteAssociationMapping(array $mapping) if ($type !== null && isset($mapping['joinColumns'])) { foreach ($mapping['joinColumns'] as &$joinColumn) { - if (!isset($joinColumn['nullable'])) { + if (! isset($joinColumn['nullable'])) { $joinColumn['nullable'] = $type->allowsNull(); } } diff --git a/tests/Doctrine/Tests/Models/CMS/CmsUserTyped.php b/tests/Doctrine/Tests/Models/CMS/CmsUserTyped.php index 829aa826bdd..09222f7889f 100644 --- a/tests/Doctrine/Tests/Models/CMS/CmsUserTyped.php +++ b/tests/Doctrine/Tests/Models/CMS/CmsUserTyped.php @@ -1,4 +1,5 @@ assertFalse($cm->isNullable('name'), "By default a field should not be nullable."); } - public function testFieldIsNullableByType() + public function testFieldIsNullableByType(): void { if (PHP_VERSION_ID < 70400) { $this->markTestSkipped('requies PHP 7.4'); @@ -113,14 +113,14 @@ public function testFieldIsNullableByType() // Implicit Not Nullable $cm->mapField(['fieldName' => 'name', 'type' => 'string', 'length' => 50]); - $this->assertFalse($cm->isNullable('name'), "By default a field should not be nullable."); + $this->assertFalse($cm->isNullable('name'), 'By default a field should not be nullable.'); // Join table Nullable $cm->mapOneToOne(['fieldName' => 'email', 'joinColumns' => [[]]]); $this->assertFalse($cm->getAssociationMapping('email')['joinColumns'][0]['nullable']); } - public function testFieldTypeFromReflection() + public function testFieldTypeFromReflection(): void { if (PHP_VERSION_ID < 70400) { $this->markTestSkipped('requies PHP 7.4'); @@ -139,7 +139,7 @@ public function testFieldTypeFromReflection() // Default string fallback $cm->mapField(['fieldName' => 'name', 'type' => 'string', 'length' => 50]); - $this->assertEquals('string', $cm->getTypeOfField('name'), "By default a field should be string."); + $this->assertEquals('string', $cm->getTypeOfField('name'), 'By default a field should be string.'); // String $cm->mapField(['fieldName' => 'dateInterval']);