Skip to content

Handle root-namespace classes in SymfonyFileLocator - #521

Merged
GromNaN merged 2 commits into
doctrine:4.2.xfrom
Junaid-PK:fix/root-namespace-mapping-message
Sep 11, 2026
Merged

GromNaN merged 2 commits into
doctrine:4.2.xfrom
Junaid-PK:fix/root-namespace-mapping-message

Conversation

@Junaid-PK

Copy link
Copy Markdown
Contributor

Fixes #520.

When a mapping lookup fails for a class in the root namespace, strrpos() returns false. The assertion then fails when assertions are enabled; when they are disabled, the subsequent substr() starts at offset 1 and reports a filename such as ateTime.yml.

Use the complete class name when there is no namespace separator, while preserving the existing short-name behavior for namespaced classes. The regression test verifies that DateTime produces the expected MappingException and filename.

Validation:

  • vendor/bin/phpunit — 146 tests, 306 assertions
  • vendor/bin/phpcs — 72 files
  • vendor/bin/phpstan analyse --no-progress --memory-limit=512M — no errors

greg0ire
greg0ire previously approved these changes Sep 10, 2026
GromNaN
GromNaN previously approved these changes Sep 11, 2026

@GromNaN GromNaN left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

Comment thread src/Mapping/Driver/SymfonyFileLocator.php Outdated
stof
stof previously approved these changes Sep 11, 2026
@Junaid-PK
Junaid-PK dismissed stale reviews from stof, GromNaN, and greg0ire via fb04176 September 11, 2026 08:36
@GromNaN
GromNaN merged commit 222ed75 into doctrine:4.2.x Sep 11, 2026
@GromNaN GromNaN added the Bug Something isn't working label Sep 11, 2026
@GromNaN GromNaN added this to the 4.2.1 milestone Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SymfonyFileLocator triggers an assertion for DateTime params

4 participants