Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1025

Please repalce 'Doctrine\XXX\YYY' with '\Doctrine\XXX\YYY' in code and document

    Details

      Description

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

        Activity

        ben yan created issue -
        Hide
        Matthieu Napoli added a comment -

        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

        Show
        Matthieu Napoli added a comment - 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
        Hide
        Karsten Dambekalns added a comment -

        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\...

        Show
        Karsten Dambekalns added a comment - 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\...
        Hide
        Benjamin Eberlei added a comment -

        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.

        Show
        Benjamin Eberlei added a comment - 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.
        Hide
        Karsten Dambekalns added a comment -

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

        Show
        Karsten Dambekalns added a comment - Yes, but the source code docblocks are what is meant here as far as I am concerned.
        Hide
        Andrey Kolyshkin added a comment -

        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;
        
        Show
        Andrey Kolyshkin added a comment - 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;
        Hide
        Miha Vrhovnik added a comment -

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

        Show
        Miha Vrhovnik added a comment - Why don't you take this to the PhpStorm tracker as it surely is a bug in IDE?
        Hide
        Karsten Dambekalns added a comment -

        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?

        Show
        Karsten Dambekalns added a comment - 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?
        Hide
        Michael Ridgway added a comment -

        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.

        Show
        Michael Ridgway added a comment - 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.
        Hide
        Andrew Mackrodt added a comment -

        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.

        Show
        Andrew Mackrodt added a comment - 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.
        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - This issue is referenced in Github Pull-Request GH-215 https://github.com/doctrine/doctrine2/pull/215
        Hide
        Benjamin Eberlei added a comment -

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

        Show
        Benjamin Eberlei added a comment - This issue is referenced in Github Pull-Request GH-216 https://github.com/doctrine/doctrine2/pull/216
        Benjamin Eberlei made changes -
        Field Original Value New Value
        Workflow jira [ 12370 ] jira-feedback [ 13910 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 13910 ] jira-feedback2 [ 15774 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15774 ] jira-feedback3 [ 18031 ]
        Show
        Steve Müller added a comment - Fixed in commits: https://github.com/doctrine/doctrine2/commit/3b259dcb42e8ba332231846401d8d97296f3dd65 https://github.com/doctrine/doctrine2/commit/bda98150c4e876f0b1b89d757c864a70ad7c583a
        Steve Müller made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.2 [ 10157 ]
        Fix Version/s 2.1 [ 10022 ]
        Resolution Fixed [ 1 ]

        This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

        • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1025, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            ben yan
          • Votes:
            7 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: