Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-876

CLI Global namespace forced on all Entity generated TypeHinting

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.0-RC1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      All, but testcase on Debian Lenny (x64/32bit) with Squeeze php packages

      Description

      When using the CLI tool to generate your entities Doctrine forces a global namespace on all TypeHints in functions. For example I used the sandbox

      See file User.php with function setAddress:

      1. public function setAddress(Address $address)

      Remove this function entirely, so that it can be generated. Then run,

      1. ./doctrine orm:generate-entities .

      Open file User.php and now the function has become:

      1. public function setAddress(\Address $address)

      note the prepended \ for global namespace

      This behaviour would be fine if all types would be in the global scope, but they're not. If you use another entity such as Address in the same namespace it should just generate the proper
      public function setAddress(Address $address)

      Or better yet, generate the Fully Qualified Namespace

      Code responsible for this:
      http://trac.doctrine-project.org/browser/trunk/lib/Doctrine/ORM/Tools/EntityGenerator.php#L609

        Activity

        Hide
        Benjamin Eberlei added a comment -

        sorry but the code you highlight here on trac is 7 months old, the current code is on Git: www.github.com/doctrine/doctrine2

        Are you really using Beta 4?

        Show
        Benjamin Eberlei added a comment - sorry but the code you highlight here on trac is 7 months old, the current code is on Git: www.github.com/doctrine/doctrine2 Are you really using Beta 4?
        Hide
        Dirk Teurlings added a comment -

        yes I'm using beta 4 It's a PEAR install.

        Sorry for the outdated URL, here's the proper one.

        https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php#L591

        Show
        Dirk Teurlings added a comment - yes I'm using beta 4 It's a PEAR install. Sorry for the outdated URL, here's the proper one. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php#L591
        Hide
        Benjamin Eberlei added a comment -

        Ah i know what is causing this issue.

        The Disconnected Metadata factory cannot know which namespace the class is in. Are you generating the code from XML or YAML?

        Show
        Benjamin Eberlei added a comment - Ah i know what is causing this issue. The Disconnected Metadata factory cannot know which namespace the class is in. Are you generating the code from XML or YAML?
        Hide
        Dirk Teurlings added a comment -

        No XML or YAML in this setup, just class files and an SQL based backend

        Show
        Dirk Teurlings added a comment - No XML or YAML in this setup, just class files and an SQL based backend
        Hide
        Benjamin Eberlei added a comment -

        Fixed

        Show
        Benjamin Eberlei added a comment - Fixed

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Dirk Teurlings
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: