mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-876: CLI Global namespace forced on all Entity generated TypeHinting #1090
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 12, 2010).
Originally assigned to: @beberlei on GitHub.
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 commented on GitHub (Nov 13, 2010):
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 commented on GitHub (Nov 13, 2010):
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 commented on GitHub (Nov 27, 2010):
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 commented on GitHub (Nov 27, 2010):
Comment created by santananl:
No XML or YAML in this setup, just class files and an SQL based backend
@doctrinebot commented on GitHub (Nov 27, 2010):
Comment created by @beberlei:
Fixed
@doctrinebot commented on GitHub (Nov 27, 2010):
Issue was closed with resolution "Fixed"