idea-php-annotation-plugin icon indicating copy to clipboard operation
idea-php-annotation-plugin copied to clipboard

Improve autocompletion for ::class constants

Open hason opened this issue 6 years ago • 3 comments

For Doctrine annotations I prefer use ::class constants over strings:

namespace App\Entity;

use App\Entity\User;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
class Post
{
    /**
     * @ORM\ManyToOne(targetEntity=User::class, inversedBy="posts")
     */
    private $author;
}

Unfortunately, the autocompletion for properties (posts) doesn't work in this case.

I would like to set in Settings whether I prefer constants or strings.

hason avatar Nov 25 '19 08:11 hason

I suggest that both ways should work automatically, without any settings.

King2500 avatar Nov 28 '19 16:11 King2500

posts should for fix latest changes on the Symfony plugin.

"::class" made it into Symfony maker bundle; maybe this should be also reflected here

Haehnchen avatar May 29 '20 18:05 Haehnchen

What I noticed is that if you ctrl+hover over a class declaration like MyClass::class, for example in Doctrine's targetEntity argument, it will correctly link it to the MyClass class, but ONLY if that class was imported with PHP's use statement in the file. If the class is within the same namespace and was not imported, as it's not necessary it will not be linked.

pkly avatar Jun 04 '20 05:06 pkly