Skip to content

Commit 43526ae

Browse files
committed
Merge branch '1.1.x' into 1.2.x
* 1.1.x: Fix wrong return type hint for selectManager Remove dupes in FileDriver::getAllClassNames
2 parents 38dc039 + 3da7c9d commit 43526ae

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function resetManager($name = null)
235235
return $this->getManager($name);
236236
}
237237

238-
private function selectManager(string $persistentObjectName, ?string $persistentManagerName = null) : ?ObjectManager
238+
private function selectManager(string $persistentObjectName, ?string $persistentManagerName = null) : ObjectManager
239239
{
240240
if ($persistentManagerName !== null) {
241241
return $this->getManager($persistentManagerName);

lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Doctrine\Common\Persistence\Mapping\MappingException;
77
use function array_keys;
88
use function array_merge;
9+
use function array_unique;
910
use function is_file;
1011
use function str_replace;
1112

@@ -126,10 +127,10 @@ public function getAllClassNames()
126127
return (array) $this->locator->getAllClassNames($this->globalBasename);
127128
}
128129

129-
return array_merge(
130+
return array_unique(array_merge(
130131
array_keys($this->classCache),
131132
(array) $this->locator->getAllClassNames($this->globalBasename)
132-
);
133+
));
133134
}
134135

135136
/**

tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,22 @@ public function testGetAllClassNamesBothSources()
101101
self::assertSame(['stdGlobal', 'stdGlobal2', 'stdClass'], $classNames);
102102
}
103103

104+
public function testGetAllClassNamesBothSourcesNoDupes() : void
105+
{
106+
$locator = $this->newLocator();
107+
$locator->expects($this->once())
108+
->method('getAllClassNames')
109+
->with($this->equalTo('global'))
110+
->willReturn(['stdClass']);
111+
$driver = new TestFileDriver($locator);
112+
$driver->setGlobalBasename('global');
113+
114+
$driver->getElement('stdClass');
115+
$classNames = $driver->getAllClassNames();
116+
117+
self::assertSame(['stdGlobal', 'stdGlobal2', 'stdClass'], $classNames);
118+
}
119+
104120
public function testIsNotTransient()
105121
{
106122
$locator = $this->newLocator();

0 commit comments

Comments
 (0)