From 2ea6a1a5fb0ad61906b32632057ce7f996312b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 19 Jun 2024 21:45:34 +0200 Subject: [PATCH 1/2] Remove unneeded CS rule --- phpcs.xml.dist | 1 - src/Mapping/InverseJoinColumn.php | 1 - 2 files changed, 2 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 6de9ebe57a2..fa28a585b6e 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -14,7 +14,6 @@ src tests - */src/Mapping/InverseJoinColumn.php */tests/Tests/Proxies/__CG__* */tests/Tests/ORM/Tools/Export/export/* diff --git a/src/Mapping/InverseJoinColumn.php b/src/Mapping/InverseJoinColumn.php index 89c8db0006b..2a77f3fc73b 100644 --- a/src/Mapping/InverseJoinColumn.php +++ b/src/Mapping/InverseJoinColumn.php @@ -2,7 +2,6 @@ declare(strict_types=1); - namespace Doctrine\ORM\Mapping; use Attribute; From 77467cd824091102cf8f82a9ff582c474d312ed2 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 2/2] 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. --- phpstan-dbal2.neon | 6 ++++ phpstan-persistence2.neon | 6 ++++ psalm-baseline.xml | 47 ------------------------------- src/Mapping/Driver/XmlDriver.php | 5 +++- src/Mapping/Driver/YamlDriver.php | 2 ++ 5 files changed, 18 insertions(+), 48 deletions(-) diff --git a/phpstan-dbal2.neon b/phpstan-dbal2.neon index 31f0f2823ab..98cba7badc1 100644 --- a/phpstan-dbal2.neon +++ b/phpstan-dbal2.neon @@ -74,3 +74,9 @@ parameters: - message: '#^Call to method injectObjectManager\(\) on an unknown class Doctrine\\Persistence\\ObjectManagerAware\.$#' path: src/UnitOfWork.php + + - + message: '#contains generic type.*but class.*is not generic#' + paths: + - src/Mapping/Driver/XmlDriver.php + - src/Mapping/Driver/YamlDriver.php diff --git a/phpstan-persistence2.neon b/phpstan-persistence2.neon index dfa68ac9ec8..931876129c3 100644 --- a/phpstan-persistence2.neon +++ b/phpstan-persistence2.neon @@ -64,3 +64,9 @@ parameters: # Symfony cache supports passing a key prefix to the clear method. - '/^Method Psr\\Cache\\CacheItemPoolInterface\:\:clear\(\) invoked with 1 parameter, 0 required\.$/' + + - + message: '#contains generic type.*but class.*is not generic#' + paths: + - src/Mapping/Driver/XmlDriver.php + - src/Mapping/Driver/YamlDriver.php 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 {