Skip to content

Commit f11adcb

Browse files
authored
Merge pull request #11689 from doctrine/3.4.x
Merge 3.4.x up into 4.0.x
2 parents 1e4b88d + 74155c8 commit f11adcb

File tree

10 files changed

+74
-226
lines changed

10 files changed

+74
-226
lines changed

docs/en/_exts/configurationblock.py

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

docs/en/make.bat

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

docs/en/tutorials/working-with-indexed-associations.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ The code and mappings for the Market entity looks like this:
3535
.. literalinclude:: working-with-indexed-associations/market.xml
3636
:language: xml
3737

38-
.. literalinclude:: working-with-indexed-associations/market.xml
39-
:language: yaml
40-
41-
4238
Inside the ``addStock()`` method you can see how we directly set the key of the association to the symbol,
4339
so that we can work with the indexed association directly after invoking ``addStock()``. Inside ``getStock($symbol)``
4440
we pick a stock traded on the particular market by symbol. If this stock doesn't exist an exception is thrown.

docs/en/tutorials/working-with-indexed-associations/market.yaml

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

doctrine-mapping.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
<xs:choice minOccurs="0" maxOccurs="unbounded">
322322
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other"/>
323323
</xs:choice>
324-
<xs:attribute name="value" type="xs:NMTOKEN" use="required"/>
324+
<xs:attribute name="value" type="orm:type" use="required"/>
325325
<xs:attribute name="class" type="orm:fqcn" use="required"/>
326326
<xs:anyAttribute namespace="##other"/>
327327
</xs:complexType>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
class CustomerType
8+
{
9+
/** @var string */
10+
public $name;
11+
12+
public function __construct(string $name)
13+
{
14+
$this->name = $name;
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
final class ExternalCustomer extends CustomerType
8+
{
9+
public function __construct(string $name)
10+
{
11+
parent::__construct($name);
12+
}
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\Tests\Models\Customer;
6+
7+
final class InternalCustomer extends CustomerType
8+
{
9+
public function __construct(string $name)
10+
{
11+
parent::__construct($name);
12+
}
13+
}

tests/Tests/ORM/Mapping/ClassMetadataTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
1414
use Doctrine\ORM\Mapping\DefaultTypedFieldMapper;
1515
use Doctrine\ORM\Mapping\DiscriminatorColumnMapping;
16+
use Doctrine\ORM\Mapping\Driver\XmlDriver;
1617
use Doctrine\ORM\Mapping\JoinTableMapping;
1718
use Doctrine\ORM\Mapping\MappedSuperclass;
1819
use Doctrine\ORM\Mapping\MappingException;
@@ -32,6 +33,7 @@
3233
use Doctrine\Tests\Models\CMS\UserRepository;
3334
use Doctrine\Tests\Models\Company\CompanyContract;
3435
use Doctrine\Tests\Models\Company\CompanyContractListener;
36+
use Doctrine\Tests\Models\Customer\CustomerType;
3537
use Doctrine\Tests\Models\CustomType\CustomTypeParent;
3638
use Doctrine\Tests\Models\DDC117\DDC117Article;
3739
use Doctrine\Tests\Models\DDC117\DDC117ArticleDetails;
@@ -1068,14 +1070,27 @@ public function testItThrowsOnInvalidCallToGetAssociationMappedByTargetField():
10681070

10691071
$metadata->getAssociationMappedByTargetField('foo');
10701072
}
1073+
1074+
public function testClassNameMappingDiscriminatorValue(): void
1075+
{
1076+
$driver = new XmlDriver(
1077+
__DIR__ . '/xml',
1078+
XmlDriver::DEFAULT_FILE_EXTENSION,
1079+
true,
1080+
);
1081+
$xmlElement = $driver->getElement(CustomerType::class);
1082+
self::assertEquals(
1083+
'Doctrine\Tests\Models\Customer\InternalCustomer',
1084+
$xmlElement->children()->{'discriminator-map'}->{'discriminator-mapping'}[0]->attributes()['value'],
1085+
);
1086+
}
10711087
}
10721088

10731089
#[MappedSuperclass]
10741090
class DDC2700MappedSuperClass
10751091
{
1076-
/** @var mixed */
10771092
#[Column]
1078-
private $foo;
1093+
private mixed $foo;
10791094
}
10801095

10811096
class MyNamespacedNamingStrategy extends DefaultNamingStrategy
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
5+
https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
6+
<entity name="Doctrine\Tests\Models\Customer\CustomerType" table="customers" inheritance-type="SINGLE_TABLE">
7+
<field name="name" column="name"/>
8+
<discriminator-column name="type" type="string"/>
9+
<discriminator-map>
10+
<discriminator-mapping value="Doctrine\Tests\Models\Customer\InternalCustomer" class="Doctrine\Tests\Models\Customer\InternalCustomer" />
11+
<discriminator-mapping value="Doctrine\Tests\Models\Customer\ExternalCustomer" class="Doctrine\Tests\Models\Customer\ExternalCustomer" />
12+
</discriminator-map>
13+
</entity>
14+
</doctrine-mapping>

0 commit comments

Comments
 (0)