Skip to content

Commit e5c4084

Browse files
authored
Merge pull request #456 from doctrine/3.4.x-merge-up-into-4.1.x_0uP2KmOr
Merge release 3.4.3 into 4.1.x
2 parents b9c49ad + 162c737 commit e5c4084

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/Persistence/Mapping/Driver/MappingDriverChain.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Doctrine\Persistence\Mapping\MappingException;
99

1010
use function array_keys;
11-
use function rtrim;
1211
use function spl_object_id;
1312
use function strpos;
1413

@@ -57,7 +56,7 @@ public function getDrivers(): array
5756
public function loadMetadataForClass(string $className, ClassMetadata $metadata): void
5857
{
5958
foreach ($this->drivers as $namespace => $driver) {
60-
if ($this->isInNamespace($className, $namespace)) {
59+
if (strpos($className, $namespace) === 0) {
6160
$driver->loadMetadataForClass($className, $metadata);
6261

6362
return;
@@ -89,7 +88,7 @@ public function getAllClassNames(): array
8988
}
9089

9190
foreach ($driverClasses[$oid] as $className) {
92-
if (! $this->isInNamespace($className, $namespace)) {
91+
if (strpos($className, $namespace) !== 0) {
9392
continue;
9493
}
9594

@@ -109,7 +108,7 @@ public function getAllClassNames(): array
109108
public function isTransient(string $className): bool
110109
{
111110
foreach ($this->drivers as $namespace => $driver) {
112-
if ($this->isInNamespace($className, $namespace)) {
111+
if (strpos($className, $namespace) === 0) {
113112
return $driver->isTransient($className);
114113
}
115114
}
@@ -120,11 +119,4 @@ public function isTransient(string $className): bool
120119

121120
return true;
122121
}
123-
124-
private function isInNamespace(string $className, string $namespace): bool
125-
{
126-
$namespace = rtrim($namespace, '\\') . '\\';
127-
128-
return strpos($className, $namespace) === 0;
129-
}
130122
}

tests/Persistence/Mapping/DriverChainTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
class DriverChainTest extends DoctrineTestCase
1919
{
20-
#[TestWith(['Doctrine\Tests\Models\Company'])]
21-
#[TestWith(['Doctrine\Tests\Persistence\Map'])]
22-
public function testDelegateToMatchingNamespaceDriver(string $namespace): void
20+
#[TestWith(['Doctrine\Tests\Models\Company', 'Doctrine\Tests\Persistence\Mapping'])]
21+
#[TestWith(['Doctrine\Tests\Persistence\Map\\', 'Doctrine\Tests\Persistence\Map'])]
22+
public function testDelegateToMatchingNamespaceDriver(string $namespace1, string $namespace2): void
2323
{
2424
$className = DriverChainEntity::class;
2525
$classMetadata = $this->createMock(ClassMetadata::class);
@@ -41,8 +41,8 @@ public function testDelegateToMatchingNamespaceDriver(string $namespace): void
4141
->with(self::equalTo($className))
4242
->willReturn(true);
4343

44-
$chain->addDriver($driver1, $namespace);
45-
$chain->addDriver($driver2, 'Doctrine\Tests\Persistence\Mapping');
44+
$chain->addDriver($driver1, $namespace1);
45+
$chain->addDriver($driver2, $namespace2);
4646

4747
$chain->loadMetadataForClass($className, $classMetadata);
4848

0 commit comments

Comments
 (0)