DDC-876: CLI Global namespace forced on all Entity generated TypeHinting #5399

Closed
doctrinebot opened this Issue Nov 12, 2010 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user santananl:

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:

public function setAddress(Address $address)

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

./doctrine orm:generate-entities .

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

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

@doctrinebot

Comment created by @beberlei:

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?

@doctrinebot

Comment created by santananl:

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

@doctrinebot

Comment created by @beberlei:

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?

@doctrinebot

Comment created by santananl:

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

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0-RC1 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment