DDC-2066: [GH-472] Fixed empty namespace in generated code when repository class do not have namespace #2603

Closed
opened 2026-01-22 13:58:13 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Oct 11, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user @beberlei:

This issue is created automatically through a Github pull request on behalf of twinh:

Url: https://github.com/doctrine/doctrine2/pull/472

Message:

When we defined a class without namespace for entity repository, just like @Entity(repositoryClass="BugRepository"), EntityRepositoryGenerator will generate the code like blow, which has error statement in namespace definition. So this is mainly added a generateEntityRepositoryNamespace method to generate the correct namespace.Just like what EntityGenerator does
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php#L492

_before_

<?php

namespace ; //caurse parse error: syntax error, unexpected ';', expecting T*STRING or T_NS*SEPARATOR or '{'

use Doctrine\ORM\EntityRepository;

/****
 * BugRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class BugRepository extends EntityRepository
{
}

_after_

<?php



use Doctrine\ORM\EntityRepository;

/****
 * BugRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class BugRepository extends EntityRepository
{
}
Originally created by @doctrinebot on GitHub (Oct 11, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user @beberlei: This issue is created automatically through a Github pull request on behalf of twinh: Url: https://github.com/doctrine/doctrine2/pull/472 Message: When we defined a class without namespace for entity repository, just like @Entity(repositoryClass="BugRepository"), EntityRepositoryGenerator will generate the code like blow, which has error statement in namespace definition. So this is mainly added a generateEntityRepositoryNamespace method to generate the correct namespace.Just like what EntityGenerator does https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php#L492 **_before**_ ``` php <?php namespace ; //caurse parse error: syntax error, unexpected ';', expecting T*STRING or T_NS*SEPARATOR or '{' use Doctrine\ORM\EntityRepository; /**** * BugRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class BugRepository extends EntityRepository { } ``` **_after**_ ``` php <?php use Doctrine\ORM\EntityRepository; /**** * BugRepository * * This class was generated by the Doctrine ORM. Add your own custom * repository methods below. */ class BugRepository extends EntityRepository { } ```
admin added the Bug label 2026-01-22 13:58:13 +01:00
admin closed this issue 2026-01-22 13:58:14 +01:00
Author
Owner

@doctrinebot commented on GitHub (Oct 22, 2012):

Comment created by @beberlei:

A related Github Pull-Request [GH-472] was closed
https://github.com/doctrine/doctrine2/pull/472

@doctrinebot commented on GitHub (Oct 22, 2012): Comment created by @beberlei: A related Github Pull-Request [GH-472] was closed https://github.com/doctrine/doctrine2/pull/472
Author
Owner

@doctrinebot commented on GitHub (Oct 25, 2012):

Comment created by @FabioBatSilva:

Merged : a16a935bff

@doctrinebot commented on GitHub (Oct 25, 2012): Comment created by @FabioBatSilva: Merged : https://github.com/doctrine/doctrine2/commit/a16a935bff27d42f0a308d4dfc11a555826310a7
Author
Owner

@doctrinebot commented on GitHub (Oct 25, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Oct 25, 2012): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 28, 2013):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-472] was closed:
https://github.com/doctrine/dbal/pull/472

@doctrinebot commented on GitHub (Dec 28, 2013): Comment created by @doctrinebot: A related Github Pull-Request [GH-472] was closed: https://github.com/doctrine/dbal/pull/472
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2603