[PhpStorm 2.0] Autocompletion and Doc Blocks issue

Hi,

I ask here before creating an issue in the tracker because maybe i'm the one who is doing something wrong :)

Use case :
http://pastie.org/1601564

Here PhpStorm don't know how to reach declarations and implementations of $this->getNewsRepository()->getListForArchive(...).
But in the getter i use correctly a @return tag so it should consider it and recognize the referenced interface.

Any idea ?


Thanks,

Benjamin.

3 comments
Comment actions Permalink

Hi Benjamin,

If I understand correctly you are having problems with getNewsRepository method. If so -- put your cursor over getNewsRepository (declaration or usage) and invoke View | Quick Documentation Lookup (Ctrl+Q). Now check which return type PhpStorm detects (alternatively you can use Structure panel for this purpose).

I may be wrong here, but I see \NewsModule\Controller\NewsRepositoryInterface instead of \NewsModule\Repository\NewsRepositoryInterface (class/interface was name resolved relative to current namespace).

If that is correct, then the change below should do the job:

    /**
     * @return \NewsModule\Repository\NewsRepositoryInterface
     */
    public function getNewsRepository()
    {
0
Comment actions Permalink

Bazzik a écrit:

Hi Benjamin,

If I understand correctly you are having problems with getNewsRepository method. If so -- put your cursor over getNewsRepository (declaration or usage) and invoke View | Quick Documentation Lookup (Ctrl+Q). Now check which return type PhpStorm detects (alternatively you can use Structure panel for this purpose).

I may be wrong here, but I see \NewsModule\Controller\NewsRepositoryInterface instead of \NewsModule\Repository\NewsRepositoryInterface (class/interface was name resolved relative to current namespace).

If that is correct, then the change below should do the job:

    /**
     * @return \NewsModule\Repository\NewsRepositoryInterface
     */
    public function getNewsRepository()
    {


Yeah, that works, but the behavior i'm talking about should be handled too.

With namespaces, my guess is that if you don't specify the "\" root it should consider first the used namespaces in the "use" statements. So @return NewsRepository should refer to the used namespace since i explicitly define the full use statement.

That makes even more sense because even with the full qualified namespace in the @return tag, PhpStorm can't reach the implementation of the interface, for IMO, exactly the same reason.

Here is a sample of the interface implementation :

namespace NewsModule\Repository\Impl;
use Doctrine\ORM\EntityRepository; use NewsModule\Repository\NewsRepositoryInterface;

class NewsDoctrineRepository extends EntityRepository implements NewsRepositoryInterface
{
    // some code...
}



The code is correct according to PHP5.3 namespaces recipes, but PhpStorm can't reach the implementation, only the declaration, that's really too bad, and over this, it is a lack :)


Benjamin.

0
Comment actions Permalink

I do not have much experience with namespaces therefore cannot really advice on what is correct and what is not (I gave my thoughts on the original issue but that is about it).

In my opinion you can safely submit new ticket on issue Tracker.

0

Please sign in to leave a comment.