DDC-1025: Please repalce 'Doctrine\XXX\YYY' with '\Doctrine\XXX\YYY' in code and document #1283

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

Originally created by @doctrinebot on GitHub (Feb 9, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user wsyb:

It will help us use the namespace and code autocomplete in some IDE.

Originally created by @doctrinebot on GitHub (Feb 9, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user wsyb: It will help us use the namespace and code autocomplete in some IDE.
admin added the Improvement label 2026-01-22 13:08:13 +01:00
admin closed this issue 2026-01-22 13:08:13 +01:00
Author
Owner

@doctrinebot commented on GitHub (Apr 8, 2011):

Comment created by matthieu:

Hi, do you have any more information about this ?

I'm confused because the php documentation uses the Doctrine\XXX way, and everywhere I've seen, it is used like that.

Thanks

@doctrinebot commented on GitHub (Apr 8, 2011): Comment created by matthieu: Hi, do you have any more information about this ? I'm confused because the php documentation uses the Doctrine\XXX way, and everywhere I've seen, it is used like that. Thanks
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2011):

Comment created by k-fish:

The issue is simple and logical. :)

When an IDE (I am using PhpStorm and it does it like this) sees a namespace in a file, upon seeing namespaces afterwards, it sees them as absolute if they have a leading backslash, or relative when it does not. This affects the resolution of classes for type navigation, code inspection, ... The same rules as for actual PHP code should be used within comments.

Here is an example:

namespace Foo;

class Bar {

  /****
   * @var Baz
   */
  protected $baz;

  /****
   * @var \Quux
   */
  protected $quux;

}

The IDE will think $baz is \Foo\Baz and $quux will be seen as being \Quux. Now if you have some reference to Doctrine here, and it was relative, the IDE would assume it's \Foo\Doctrine...

@doctrinebot commented on GitHub (Apr 11, 2011): Comment created by k-fish: The issue is simple and logical. :) When an IDE (I am using PhpStorm and it does it like this) sees a namespace in a file, upon seeing namespaces afterwards, it sees them as absolute if they have a leading backslash, or relative when it does not. This affects the resolution of classes for type navigation, code inspection, ... The same rules as for actual PHP code should be used within comments. Here is an example: ``` namespace Foo; class Bar { /**** * @var Baz */ protected $baz; /**** * @var \Quux */ protected $quux; } ``` The IDE will think $baz is \Foo\Baz and $quux will be seen as being \Quux. Now if you have some reference to Doctrine here, and it was relative, the IDE would assume it's \Foo\Doctrine...
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2011):

Comment created by @beberlei:

Well yes, but since all our code examples have no leading namespace argument this means the code is in the default namespace, making Doctrine\XXX\YY a relative namespace that is actually valid.

@doctrinebot commented on GitHub (Apr 11, 2011): Comment created by @beberlei: Well yes, but since all our code examples have no leading namespace argument this means the code is in the default namespace, making Doctrine\XXX\YY a relative namespace that is actually valid.
Author
Owner

@doctrinebot commented on GitHub (Apr 11, 2011):

Comment created by k-fish:

Yes, but the source code docblocks are what is meant here as far as I am concerned.

@doctrinebot commented on GitHub (Apr 11, 2011): Comment created by k-fish: Yes, but the source code docblocks are what is meant here as far as I am concerned.
Author
Owner

@doctrinebot commented on GitHub (May 13, 2011):

Comment created by morfi:

Example (Entitymanager.php):

namespace Doctrine\ORM;

and

/****
  * The used Configuration.
  *
  * @var Doctrine\ORM\Configuration
  */
   private $config;

Result:
Doctrine\ORM\Doctrine\ORM\Configuration

Should be:

/****
  * The used Configuration.
  *
  * @var Configuration
  */
   private $config;

Or

/****
  * The used Configuration.
  *
  * @var \Doctrine\ORM\Configuration
  */
   private $config;
@doctrinebot commented on GitHub (May 13, 2011): Comment created by morfi: Example (Entitymanager.php): ``` namespace Doctrine\ORM; ``` and ``` /**** * The used Configuration. * * @var Doctrine\ORM\Configuration */ private $config; ``` Result: **Doctrine\ORM\Doctrine\ORM\Configuration** Should be: ``` /**** * The used Configuration. * * @var Configuration */ private $config; ``` Or ``` /**** * The used Configuration. * * @var \Doctrine\ORM\Configuration */ private $config; ```
Author
Owner

@doctrinebot commented on GitHub (May 27, 2011):

Comment created by mvrhov:

Why don't you take this to the PhpStorm tracker as it surely is a bug in IDE?

@doctrinebot commented on GitHub (May 27, 2011): Comment created by mvrhov: Why don't you take this to the PhpStorm tracker as it surely is a bug in IDE?
Author
Owner

@doctrinebot commented on GitHub (May 27, 2011):

Comment created by k-fish:

Miha, what makes you think it's an IDE bug? In a class in namespace Foo another class named Bar is \Foo\Bar, but \Bar is \Bar. Why is it a bug if the IDE follows the namespace resolution rules?

@doctrinebot commented on GitHub (May 27, 2011): Comment created by k-fish: Miha, what makes you think it's an IDE bug? In a class in namespace Foo another class named Bar is \Foo\Bar, but \Bar is \Bar. Why is it a bug if the IDE follows the namespace resolution rules?
Author
Owner

@doctrinebot commented on GitHub (Jul 11, 2011):

Comment created by mridgway:

The issue is that PHPStorm and NetBeans have different class resolution rules. I also use PHPStorm and most of Doctrine does not resolve auto-completion correctly because of this issue.

I'd be willing to work on this if it would be accepted.

@doctrinebot commented on GitHub (Jul 11, 2011): Comment created by mridgway: The issue is that PHPStorm and NetBeans have different class resolution rules. I also use PHPStorm and most of Doctrine does not resolve auto-completion correctly because of this issue. I'd be willing to work on this if it would be accepted.
Author
Owner

@doctrinebot commented on GitHub (Sep 29, 2011):

Comment created by andrewmackrodt:

I've been evaluating PhpStorm and also came across this issue; I believe the problem is due to Doctrine rather than being a bug with the IDE although it would be nice if PhpStorm would assume namespaces are absolute if they're not resolved upon an initial lookup.

I created a quick c# app to append the beginning forward slash to any @var or @return attributes within Doctrine's source. It's working for me with Doctrine 2.1.2 and PhpStorm (IntelliJ): http://pastebin.com/4HxiWvJA - hopefully this will be of use for anyone else using these IDEs;. Note: the application doesn't detect multiple line annotations although the only one I'm aware of is the getAST method in Doctrine\ORM\Query.php.

@doctrinebot commented on GitHub (Sep 29, 2011): Comment created by andrewmackrodt: I've been evaluating PhpStorm and also came across this issue; I believe the problem is due to Doctrine rather than being a bug with the IDE although it would be nice if PhpStorm would assume namespaces are absolute if they're not resolved upon an initial lookup. I created a quick c# app to append the beginning forward slash to any @var or @return attributes within Doctrine's source. It's working for me with Doctrine 2.1.2 and PhpStorm (IntelliJ): http://pastebin.com/4HxiWvJA - hopefully this will be of use for anyone else using these IDEs;. Note: the application doesn't detect multiple line annotations although the only one I'm aware of is the getAST method in Doctrine\ORM\Query.php.
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2011):

Comment created by @beberlei:

This issue is referenced in Github Pull-Request GH-215
https://github.com/doctrine/doctrine2/pull/215

@doctrinebot commented on GitHub (Dec 13, 2011): Comment created by @beberlei: This issue is referenced in Github Pull-Request GH-215 https://github.com/doctrine/doctrine2/pull/215
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2011):

Comment created by @beberlei:

This issue is referenced in Github Pull-Request GH-216
https://github.com/doctrine/doctrine2/pull/216

@doctrinebot commented on GitHub (Dec 13, 2011): Comment created by @beberlei: This issue is referenced in Github Pull-Request GH-216 https://github.com/doctrine/doctrine2/pull/216
Author
Owner

@doctrinebot commented on GitHub (Apr 1, 2014):

Comment created by @deeky666:

Fixed in commits:
3b259dcb42
bda98150c4

@doctrinebot commented on GitHub (Apr 1, 2014): Comment created by @deeky666: Fixed in commits: https://github.com/doctrine/doctrine2/commit/3b259dcb42e8ba332231846401d8d97296f3dd65 https://github.com/doctrine/doctrine2/commit/bda98150c4e876f0b1b89d757c864a70ad7c583a
Author
Owner

@doctrinebot commented on GitHub (Apr 1, 2014):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Apr 1, 2014): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1283