DDC-385: Change behaviour if fully qualified classname is passed in as string #479

Closed
opened 2026-01-22 12:39:36 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 1, 2010).

Jira issue originally created by user shurakai:

If one calls $em->getRepository('\Entity') (leading \ !) then Doctrine's behaviour is quite undefined, as it would result e.g. in a "mapping file '.entity.dcm.yml' not found" error. (leading dot!)

PHP, however, seems to allow the leading , but Doctrine does not. In fact, the leading \ is not necessary as classnames in strings are always fully qualified.

So Doctrine should either:

1.) Throw an exception stating that using a leading backslash is prohibited
2.) Simply strip it.

Originally created by @doctrinebot on GitHub (Mar 1, 2010). Jira issue originally created by user shurakai: If one calls $em->getRepository('\Entity') (leading \ !) then Doctrine's behaviour is quite undefined, as it would result e.g. in a "mapping file '.entity.dcm.yml' not found" error. (leading dot!) PHP, however, seems to allow the leading \, but Doctrine does not. In fact, the leading \ is not necessary as classnames in strings are always fully qualified. So Doctrine should either: 1.) Throw an exception stating that using a leading backslash is prohibited 2.) Simply strip it.
admin added the Improvement label 2026-01-22 12:39:36 +01:00
admin closed this issue 2026-01-22 12:39:37 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 1, 2010):

Comment created by @beberlei:

I vote for 1. Stripping the char just leads to major overhead given that getMetadataFor is one of the most called functions in Doctrine 2.

@doctrinebot commented on GitHub (Mar 1, 2010): Comment created by @beberlei: I vote for 1. Stripping the char just leads to major overhead given that getMetadataFor is one of the most called functions in Doctrine 2.
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2010):

Comment created by romanb:

Fixed.

@doctrinebot commented on GitHub (Aug 8, 2010): Comment created by romanb: Fixed.
Author
Owner

@doctrinebot commented on GitHub (Aug 8, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Aug 8, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#479