From fa731b10ec620f5f4cae62ff4c5f4a05452e67f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 8 Jan 2022 14:12:04 +0100 Subject: [PATCH] Mark columnName as always set This is enforced before writing to the property that holds FieldMapping arrays. As shown by the static analysis baselines reduction, this existence is relied on throughout the codebase. --- .../ORM/Mapping/ClassMetadataInfo.php | 2 +- .../ORM/Tools/Export/Driver/XmlExporter.php | 5 +-- phpstan-baseline.neon | 2 +- psalm-baseline.xml | 45 +------------------ 4 files changed, 4 insertions(+), 50 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 442de0ae98c..168f8961fc4 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -73,7 +73,7 @@ * @psalm-type FieldMapping = array{ * type: string, * fieldName: string, - * columnName?: string, + * columnName: string, * length?: int, * id?: bool, * nullable?: bool, diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php index c854cff8233..8c9ce6d7b92 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -178,10 +178,7 @@ public function exportClassMetadata(ClassMetadataInfo $metadata) $fieldXml = $root->addChild('field'); $fieldXml->addAttribute('name', $field['fieldName']); $fieldXml->addAttribute('type', $field['type']); - - if (isset($field['columnName'])) { - $fieldXml->addAttribute('column', $field['columnName']); - } + $fieldXml->addAttribute('column', $field['columnName']); if (isset($field['length'])) { $fieldXml->addAttribute('length', (string) $field['length']); diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c10d97a9431..1329633957b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -2191,7 +2191,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Offset 'version' on array\\{type\\: string, fieldName\\: string, columnName\\?\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, precision\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#" + message: "#^Offset 'version' on array\\{type\\: string, fieldName\\: string, columnName\\: string, length\\?\\: int, id\\?\\: bool, nullable\\?\\: bool, columnDefinition\\?\\: string, precision\\?\\: int, \\.\\.\\.\\} in isset\\(\\) does not exist\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index eb2310afd51..dd578c16472 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -102,9 +102,6 @@ loadCacheEntry - - $fieldMapping['columnName'] - getCacheRegion @@ -712,11 +709,6 @@ matching - - - $class->fieldMappings[$fieldName]['columnName'] - - $fetch @@ -1009,18 +1001,10 @@ setValue setValue - - $fieldMapping['columnName'] - $fieldMapping['columnName'] - $mapping['columnName'] + $mapping['originalClass'] $mapping['originalField'] $mapping['targetEntity'] - $this->fieldMappings[$field]['columnName'] - $this->fieldMappings[$field]['columnName'] - $this->fieldMappings[$idProperty]['columnName'] - $this->fieldMappings[$idProperty]['columnName'] - $this->fieldMappings[$idProperty]['columnName'] $idGenerator @@ -1091,10 +1075,6 @@ $joinColumn - - $class->fieldMappings[$fieldName]['columnName'] - $class->fieldMappings[$fieldName]['columnName'] - @@ -1779,11 +1759,6 @@ $targetClass->associationMappings - - - $fieldMapping['columnName'] - - $this->em @@ -1839,10 +1814,6 @@ getValue setValue - - $fieldMapping['columnName'] - $fieldMapping['columnName'] - $insertSql @@ -2151,9 +2122,6 @@ $class->associationMappings - - $field['columnName'] - $fieldMapping $pathExpression @@ -2841,9 +2809,6 @@ getShortName getShortName - - $class->fieldMappings[$this->fieldMappings[$columnName]]['columnName'] - @@ -2923,11 +2888,6 @@ dispatch - - $fieldMapping['columnName'] - $mapping['columnName'] - $mapping['columnName'] - $query $this->queryComponents @@ -3640,9 +3600,6 @@ $_extension - - $fieldMapping['columnName'] - $metadata->table isset($metadata->lifecycleCallbacks)