Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for entity namespaces (Foo:Bar) #6935

Merged
merged 1 commit into from
Jan 12, 2018

Conversation

Majkl578
Copy link
Contributor

Another possibly controversial PR removing existing feature. Entity namespaces are basically obsolete since PHP 5.5 released 4.5 years ago and are superseded by much safer ::class pseudo-constant, which is refactoring- and autocomplete-friendly in IDEs.

@Majkl578 Majkl578 added this to the 3.0 milestone Dec 22, 2017
Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Xymanek
Copy link

Xymanek commented Dec 31, 2017

I'm using this notation in DQL rather than FQCN as they can be quite long. Take a look at following:

  • Acme\Cms\Modules\BlogModule\Entity\Article (yes, this is a bit on extreme side but it shows the idea)
  • Blog:Article or BlogModule:Article

Removing this feature will make using DQL without builder quite cumbersome I think

@Majkl578
Copy link
Contributor Author

Majkl578 commented Dec 31, 2017

Removing this feature will make using DQL without builder quite cumbersome I think

The issue with entity namespaces is that they're solving a problem that doesn't exist anymore (it did back then when Doctrine 2.0 was released for PHP 5.3, ::class is PHP 5.5+). Furthermore, it makes code harder to maintain, harder to read (subjectively) and harder to refactor (rename class, move to different namespace).

SELECT a FROM BlogModule:Article a WHERE a.author = :author

would become:

SELECT a FROM ' . Article::class . ' a WHERE a.author = :author

And with query builder, you won't even need string concatenation:

$qb->select('a')
    ->from(Article::class, 'a')
    ->where('a.author = :author')

@Majkl578 Majkl578 force-pushed the dev/entity-namespace-removal branch from c269872 to a4e32b7 Compare January 1, 2018 20:03
@Majkl578 Majkl578 force-pushed the dev/entity-namespace-removal branch 2 times, most recently from ffe4c72 to f304f34 Compare January 2, 2018 19:03
@Majkl578 Majkl578 changed the base branch from develop to master January 2, 2018 20:28
@Majkl578
Copy link
Contributor Author

Finally ready for shipping. :shipit:

@Majkl578 Majkl578 merged commit ea95507 into doctrine:master Jan 12, 2018
@Majkl578 Majkl578 deleted the dev/entity-namespace-removal branch January 12, 2018 20:48
@greg0ire greg0ire added this to To consider 🤔 in Backports via automation Jun 27, 2021
@greg0ire greg0ire removed this from the 3.0.0 milestone Jun 27, 2021
@beberlei beberlei moved this from To consider 🤔 to To Do 👍 in Backports Jul 4, 2021
@beberlei beberlei moved this from To Do Doctrine 2.10.x to Todo Doctrine 3 in Backports Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Backports
  
Todo Doctrine 3.0.x
ORM.NEXT
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

4 participants