From 7ea9c318fcadeb525ab36155453182018591112b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 20 Jun 2024 21:47:54 +0200 Subject: [PATCH] Address doctrine/persistence 3.3.3 release FileDriver became templatable, and some very wrong phpdoc has been fixed, causing Psalm to better understand the 2 FileDriver classes in this project. --- psalm-baseline.xml | 47 ------------------------------- src/Mapping/Driver/XmlDriver.php | 5 +++- src/Mapping/Driver/YamlDriver.php | 2 ++ 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2be2ff0b8c3..b9473bebb66 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -932,13 +932,8 @@ table]]> - - {'discriminator-column'}]]> - {'discriminator-map'}]]> - - $usage, 'region' => $region, @@ -962,7 +957,6 @@ * options?: array * }]]> - @@ -971,15 +965,6 @@ - - {'discriminator-column'}]]> - {'discriminator-map'}]]> - - - getName() === 'embeddable']]> - getName() === 'entity']]> - getName() === 'mapped-superclass']]> - @@ -1011,38 +996,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Mapping/Driver/XmlDriver.php b/src/Mapping/Driver/XmlDriver.php index 60223020dc9..c993a2ba794 100644 --- a/src/Mapping/Driver/XmlDriver.php +++ b/src/Mapping/Driver/XmlDriver.php @@ -37,6 +37,8 @@ * XmlDriver is a metadata driver that enables mapping through XML files. * * @link www.doctrine-project.org + * + * @template-extends FileDriver */ class XmlDriver extends FileDriver { @@ -79,7 +81,6 @@ public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENS public function loadMetadataForClass($className, PersistenceClassMetadata $metadata) { $xmlRoot = $this->getElement($className); - assert($xmlRoot instanceof SimpleXMLElement); if ($xmlRoot->getName() === 'entity') { if (isset($xmlRoot['repository-class'])) { @@ -203,6 +204,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad ]; if (isset($discrColumn['options'])) { + assert($discrColumn['options'] instanceof SimpleXMLElement); $columnDef['options'] = $this->parseOptions($discrColumn['options']->children()); } @@ -214,6 +216,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad // Evaluate if (isset($xmlRoot->{'discriminator-map'})) { $map = []; + assert($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} instanceof SimpleXMLElement); foreach ($xmlRoot->{'discriminator-map'}->{'discriminator-mapping'} as $discrMapElement) { $map[(string) $discrMapElement['value']] = (string) $discrMapElement['class']; } diff --git a/src/Mapping/Driver/YamlDriver.php b/src/Mapping/Driver/YamlDriver.php index c6ff83e0f17..5e24b0b3a45 100644 --- a/src/Mapping/Driver/YamlDriver.php +++ b/src/Mapping/Driver/YamlDriver.php @@ -31,6 +31,8 @@ * The YamlDriver reads the mapping metadata from yaml schema files. * * @deprecated 2.7 This class is being removed from the ORM and won't have any replacement + * + * @template-extends FileDriver> */ class YamlDriver extends FileDriver {