diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index c99f74c1..7bd76d27 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -12,4 +12,4 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@15.0.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@15.1.0" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f96e78c8..6ffae26e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -12,7 +12,7 @@ on: jobs: phpunit: name: "PHPUnit" - uses: "doctrine/.github/.github/workflows/continuous-integration.yml@15.0.0" + uses: "doctrine/.github/.github/workflows/continuous-integration.yml@15.1.0" with: php-versions: '["8.1", "8.2", "8.3", "8.4", "8.5"]' phpunit-options-lowest: "--do-not-fail-on-deprecation" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 640f06bd..04037de7 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -17,4 +17,4 @@ on: jobs: documentation: name: "Documentation" - uses: "doctrine/.github/.github/workflows/documentation.yml@15.0.0" + uses: "doctrine/.github/.github/workflows/documentation.yml@15.1.0" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 7100986c..786e150b 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@15.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@15.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 3d078651..dc26e323 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -12,4 +12,4 @@ on: jobs: static-analysis: name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/phpstan.yml@15.0.0" + uses: "doctrine/.github/.github/workflows/phpstan.yml@15.1.0" diff --git a/src/ManagerRegistry.php b/src/ManagerRegistry.php index 2e0a389c..43ac855d 100644 --- a/src/ManagerRegistry.php +++ b/src/ManagerRegistry.php @@ -5,7 +5,7 @@ namespace Doctrine\Persistence; /** - * Contract covering object managers for a Doctrine persistence layer ManagerRegistry class to implement. + * Gives access to the object managers and connections of an application, by name or by class. */ interface ManagerRegistry extends ConnectionRegistry { diff --git a/src/Mapping/Driver/SymfonyFileLocator.php b/src/Mapping/Driver/SymfonyFileLocator.php index 09339fae..5d9b1ceb 100644 --- a/src/Mapping/Driver/SymfonyFileLocator.php +++ b/src/Mapping/Driver/SymfonyFileLocator.php @@ -11,16 +11,14 @@ use RuntimeException; use function array_keys; -use function assert; +use function basename; use function is_dir; use function is_file; -use function is_int; use function realpath; use function sprintf; use function str_replace; use function str_starts_with; use function strlen; -use function strrpos; use function strtr; use function substr; @@ -222,12 +220,9 @@ public function findMappingFile(string $className): string } } - $pos = strrpos($className, '\\'); - assert(is_int($pos)); - throw MappingException::mappingFileNotFound( $className, - substr($className, $pos + 1) . $this->fileExtension, + basename(str_replace('\\', '/', $className)) . $this->fileExtension, ); } diff --git a/tests/Mapping/SymfonyFileLocatorTest.php b/tests/Mapping/SymfonyFileLocatorTest.php index ff7767d8..0b58d5b4 100644 --- a/tests/Mapping/SymfonyFileLocatorTest.php +++ b/tests/Mapping/SymfonyFileLocatorTest.php @@ -188,6 +188,15 @@ public function testFindMappingFileNotFound(): void $locator->findMappingFile('Foo\\stdClass2'); } + public function testFindMappingFileNotFoundForClassInRootNamespace(): void + { + $locator = new SymfonyFileLocator([], '.yml'); + + $this->expectException(MappingException::class); + $this->expectExceptionMessage("No mapping file found named 'DateTime.yml' for class 'DateTime'."); + $locator->findMappingFile('DateTime'); + } + public function testFindMappingFileLeastSpecificNamespaceFirst(): void { // Low -> High