Skip to content

Commit b6545cc

Browse files
committed
Merge branch '3.4.x' into 4.1.x
2 parents eca73be + 06a5956 commit b6545cc

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ on:
1212
jobs:
1313
coding-standards:
1414
name: "Coding Standards"
15-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@8.0.0"
15+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@12.0.0"

.github/workflows/continuous-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
phpunit:
1414
name: "PHPUnit"
15-
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@8.0.0"
15+
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@12.0.0"
1616
with:
1717
php-versions: '["8.1", "8.2", "8.3", "8.4", "8.5"]'
1818
secrets:

.github/workflows/release-on-milestone-closed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
release:
1010
name: "Git tag, release & create merge-up PR"
11-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@8.0.0"
11+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@12.0.0"
1212
secrets:
1313
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1414
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ on:
1212
jobs:
1313
static-analysis:
1414
name: "Static Analysis"
15-
uses: "doctrine/.github/.github/workflows/phpstan.yml@8.0.0"
15+
uses: "doctrine/.github/.github/workflows/phpstan.yml@12.0.0"

src/Persistence/Mapping/Driver/MappingDriverChain.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
use Doctrine\Persistence\Mapping\MappingException;
99

1010
use function array_keys;
11+
use function rtrim;
1112
use function spl_object_id;
12-
use function str_starts_with;
13+
use function strpos;
1314

1415
/**
1516
* The DriverChain allows you to add multiple other mapping drivers for
@@ -56,7 +57,7 @@ public function getDrivers(): array
5657
public function loadMetadataForClass(string $className, ClassMetadata $metadata): void
5758
{
5859
foreach ($this->drivers as $namespace => $driver) {
59-
if (str_starts_with($className, $namespace)) {
60+
if ($this->isInNamespace($className, $namespace)) {
6061
$driver->loadMetadataForClass($className, $metadata);
6162

6263
return;
@@ -88,7 +89,7 @@ public function getAllClassNames(): array
8889
}
8990

9091
foreach ($driverClasses[$oid] as $className) {
91-
if (! str_starts_with($className, $namespace)) {
92+
if (! $this->isInNamespace($className, $namespace)) {
9293
continue;
9394
}
9495

@@ -108,7 +109,7 @@ public function getAllClassNames(): array
108109
public function isTransient(string $className): bool
109110
{
110111
foreach ($this->drivers as $namespace => $driver) {
111-
if (str_starts_with($className, $namespace)) {
112+
if ($this->isInNamespace($className, $namespace)) {
112113
return $driver->isTransient($className);
113114
}
114115
}
@@ -119,4 +120,11 @@ public function isTransient(string $className): bool
119120

120121
return true;
121122
}
123+
124+
private function isInNamespace(string $className, string $namespace): bool
125+
{
126+
$namespace = rtrim($namespace, '\\') . '\\';
127+
128+
return strpos($className, $namespace) === 0;
129+
}
122130
}

tests/Persistence/Mapping/DriverChainTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
class DriverChainTest extends DoctrineTestCase
1818
{
19-
public function testDelegateToMatchingNamespaceDriver(): void
19+
/**
20+
* @testWith ["Doctrine\\Tests\\Models\\Company"]
21+
* ["Doctrine\\Tests\\Persistence\\Map"]
22+
*/
23+
public function testDelegateToMatchingNamespaceDriver(string $namespace): void
2024
{
2125
$className = DriverChainEntity::class;
2226
$classMetadata = $this->createMock(ClassMetadata::class);
@@ -38,7 +42,7 @@ public function testDelegateToMatchingNamespaceDriver(): void
3842
->with(self::equalTo($className))
3943
->willReturn(true);
4044

41-
$chain->addDriver($driver1, 'Doctrine\Tests\Models\Company');
45+
$chain->addDriver($driver1, $namespace);
4246
$chain->addDriver($driver2, 'Doctrine\Tests\Persistence\Mapping');
4347

4448
$chain->loadMetadataForClass($className, $classMetadata);

0 commit comments

Comments
 (0)