idea-php-annotation-plugin
idea-php-annotation-plugin copied to clipboard
Improve autocompletion for ::class constants
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.
I suggest that both ways should work automatically, without any settings.
posts should for fix latest changes on the Symfony plugin.
"::class" made it into Symfony maker bundle; maybe this should be also reflected here
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.