Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6583923

Browse files
committed
Merge branch '2.9.x' into merge/2.9.x
* 2.9.x: Remove Proxy from EntityManagerInterface contract Add extension point for the "embedded" XML node (doctrine#8992) Fix return type at `EntityManagerInterface::get(Partial)Reference()` (doctrine#8922) Fix class casing and avoid name collisions Remove unused performance base test class Drop unused test base classes Fix mapped superclass missing in discriminator map
2 parents 01ab70d + d1cd804 commit 6583923

10 files changed

Lines changed: 68 additions & 111 deletions

doctrine-mapping.xsd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@
281281
</xs:complexType>
282282

283283
<xs:complexType name="embedded">
284+
<xs:sequence>
285+
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
286+
</xs:sequence>
284287
<xs:attribute name="name" type="xs:string" use="required" />
285288
<xs:attribute name="class" type="orm:fqcn" use="optional" />
286289
<xs:attribute name="column-prefix" type="xs:string" use="optional" />

lib/Doctrine/ORM/EntityManagerInterface.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public function createQueryBuilder();
173173
* @psalm-param class-string<T> $entityName
174174
*
175175
* @return object|null The entity reference.
176-
* @psalm-return ?T
176+
* @psalm-return T|null
177177
*
178178
* @throws ORMException
179179
*
@@ -198,8 +198,12 @@ public function getReference($entityName, $id);
198198
*
199199
* @param string $entityName The name of the entity type.
200200
* @param mixed $identifier The entity identifier.
201+
* @psalm-param class-string<T> $entityName
202+
*
203+
* @return object|null The (partial) entity reference
204+
* @psalm-return T|null
201205
*
202-
* @return object|null The (partial) entity reference.
206+
* @template T
203207
*/
204208
public function getPartialReference($entityName, $identifier);
205209

lib/Doctrine/ORM/Tools/SchemaValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public function validateClass(ClassMetadataInfo $class)
239239
}
240240
}
241241

242-
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && array_search($class->name, $class->discriminatorMap, true) === false) {
242+
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) {
243243
$ce[] = "Entity class '" . $class->name . "' is part of inheritance hierarchy, but is " .
244244
"not mapped in the root entity '" . $class->rootEntityName . "' discriminator map. " .
245245
'All subclasses must be listed in the discriminator map.';

phpcs.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@
245245
<exclude-pattern>lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php</exclude-pattern>
246246
<exclude-pattern>lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php</exclude-pattern>
247247
<!-- the impact of changing this would be too big -->
248-
<exclude-pattern>tests/Doctrine/Tests/DbalFunctionalTestCase.php</exclude-pattern>
249248
<exclude-pattern>tests/Doctrine/Tests/OrmFunctionalTestCase.php</exclude-pattern>
250249
</rule>
251250
<rule ref="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps">

phpstan-baseline.neon

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ parameters:
155155
count: 3
156156
path: lib/Doctrine/ORM/EntityManager.php
157157

158+
-
159+
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\.$#"
160+
count: 1
161+
path: lib/Doctrine/ORM/EntityManager.php
162+
163+
-
164+
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getPartialReference\\(\\) should return T\\|null but returns object\\|null\\.$#"
165+
count: 1
166+
path: lib/Doctrine/ORM/EntityManager.php
167+
158168
-
159169
message: "#^Method Doctrine\\\\ORM\\\\EntityManager\\:\\:getReference\\(\\) should return T\\|null but returns Doctrine\\\\Common\\\\Proxy\\\\Proxy\\.$#"
160170
count: 1

psalm-baseline.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,18 +462,21 @@
462462
<code>is_object($entity)</code>
463463
<code>is_object($entity)</code>
464464
</DocblockTypeContradiction>
465-
<InvalidReturnStatement occurrences="7">
465+
<InvalidReturnStatement occurrences="9">
466+
<code>$entity</code>
466467
<code>$entity</code>
467468
<code>$entity</code>
468469
<code>$entity</code>
469470
<code>$entity instanceof $class-&gt;name ? $entity : null</code>
471+
<code>$entity instanceof $class-&gt;name ? $entity : null</code>
470472
<code>$persister-&gt;load($sortedId, null, null, [], $lockMode)</code>
471473
<code>$persister-&gt;loadById($sortedId)</code>
472474
<code>$this-&gt;metadataFactory-&gt;getMetadataFor($className)</code>
473475
</InvalidReturnStatement>
474-
<InvalidReturnType occurrences="3">
476+
<InvalidReturnType occurrences="4">
475477
<code>?T</code>
476478
<code>getClassMetadata</code>
479+
<code>getPartialReference</code>
477480
<code>getReference</code>
478481
</InvalidReturnType>
479482
<InvalidScalarArgument occurrences="1">

tests/Doctrine/Tests/DbalFunctionalTestCase.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

tests/Doctrine/Tests/DbalTestCase.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\ORM\EntityManager;
99
use Doctrine\ORM\Mapping\Column;
10+
use Doctrine\ORM\Mapping\DiscriminatorMap;
1011
use Doctrine\ORM\Mapping\Embeddable;
1112
use Doctrine\ORM\Mapping\Entity;
1213
use Doctrine\ORM\Mapping\GeneratedValue;
1314
use Doctrine\ORM\Mapping\Id;
15+
use Doctrine\ORM\Mapping\InheritanceType;
1416
use Doctrine\ORM\Mapping\JoinColumn;
1517
use Doctrine\ORM\Mapping\JoinTable;
1618
use Doctrine\ORM\Mapping\ManyToMany;
1719
use Doctrine\ORM\Mapping\ManyToOne;
20+
use Doctrine\ORM\Mapping\MappedSuperclass;
1821
use Doctrine\ORM\Mapping\OneToMany;
1922
use Doctrine\ORM\Mapping\OneToOne;
2023
use Doctrine\ORM\Mapping\OrderBy;
@@ -211,6 +214,46 @@ public function testInvalidAssociationInsideEmbeddable(): void
211214
$ce
212215
);
213216
}
217+
218+
/**
219+
* @group 8771
220+
*/
221+
public function testMappedSuperclassNotPresentInDiscriminator(): void
222+
{
223+
$class1 = $this->em->getClassMetadata(MappedSuperclassEntity::class);
224+
$ce = $this->validator->validateClass($class1);
225+
226+
$this->assertEquals([], $ce);
227+
}
228+
}
229+
230+
/**
231+
* @MappedSuperclass
232+
*/
233+
abstract class MappedSuperclassEntity extends ParentEntity
234+
{
235+
}
236+
237+
/**
238+
* @Entity
239+
* @InheritanceType("SINGLE_TABLE")
240+
* @DiscriminatorMap({"child" = ChildEntity::class})
241+
*/
242+
abstract class ParentEntity
243+
{
244+
/**
245+
* @var mixed
246+
* @Id
247+
* @Column
248+
*/
249+
protected $key;
250+
}
251+
252+
/**
253+
* @Entity
254+
*/
255+
class ChildEntity extends MappedSuperclassEntity
256+
{
214257
}
215258

216259
/**

tests/Doctrine/Tests/OrmPerformanceTestCase.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)