Skip to content

Commit

Permalink
Address doctrine/persistence 3.3.3 release
Browse files Browse the repository at this point in the history
FileDriver became templatable, and some very wrong phpdoc has been
fixed, causing Psalm to better understand the 2 FileDriver classes in
this project.
  • Loading branch information
greg0ire committed Jun 20, 2024
1 parent 802f20b commit 77467cd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 48 deletions.
6 changes: 6 additions & 0 deletions phpstan-dbal2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions phpstan-persistence2.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 0 additions & 47 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -932,13 +932,8 @@
<InvalidPropertyAssignmentValue>
<code><![CDATA[$metadata->table]]></code>
</InvalidPropertyAssignmentValue>
<InvalidPropertyFetch>
<code><![CDATA[$xmlRoot->{'discriminator-column'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
</InvalidPropertyFetch>
<InvalidReturnStatement>
<code><![CDATA[$mapping]]></code>
<code><![CDATA[$result]]></code>
<code><![CDATA[[
'usage' => $usage,
'region' => $region,
Expand All @@ -962,7 +957,6 @@
* options?: array
* }]]></code>
<code><![CDATA[array{usage: int|null, region?: string}]]></code>
<code><![CDATA[loadMappingFile]]></code>
</InvalidReturnType>
<MissingParamType>
<code><![CDATA[$fileExtension]]></code>
Expand All @@ -971,15 +965,6 @@
<MoreSpecificImplementedParamType>
<code><![CDATA[$metadata]]></code>
</MoreSpecificImplementedParamType>
<NoInterfaceProperties>
<code><![CDATA[$xmlRoot->{'discriminator-column'}]]></code>
<code><![CDATA[$xmlRoot->{'discriminator-map'}]]></code>
</NoInterfaceProperties>
<TypeDoesNotContainType>
<code><![CDATA[$xmlRoot->getName() === 'embeddable']]></code>
<code><![CDATA[$xmlRoot->getName() === 'entity']]></code>
<code><![CDATA[$xmlRoot->getName() === 'mapped-superclass']]></code>
</TypeDoesNotContainType>
</file>
<file src="src/Mapping/Driver/YamlDriver.php">
<ArgumentTypeCoercion>
Expand Down Expand Up @@ -1011,38 +996,6 @@
<MoreSpecificReturnType>
<code><![CDATA[array{usage: int|null, region: string|null}]]></code>
</MoreSpecificReturnType>
<PossiblyUndefinedMethod>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
</PossiblyUndefinedMethod>
<UndefinedInterfaceMethod>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
<code><![CDATA[$element]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/Mapping/Embedded.php">
<MissingParamType>
Expand Down
5 changes: 4 additions & 1 deletion src/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* XmlDriver is a metadata driver that enables mapping through XML files.
*
* @link www.doctrine-project.org
*
* @template-extends FileDriver<SimpleXMLElement>
*/
class XmlDriver extends FileDriver
{
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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());
}

Expand All @@ -214,6 +216,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad
// Evaluate <discriminator-map...>
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'];
}
Expand Down
2 changes: 2 additions & 0 deletions src/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<array<string, mixed>>
*/
class YamlDriver extends FileDriver
{
Expand Down

0 comments on commit 77467cd

Please sign in to comment.