Symfony 3.3 Doctrine, entity from db -> no type hinting.
Hello. I tried to make the title as descriptive as possible.
So, I got this weird kind of behavior from PHPStorm.
If I fill an entity object from the db everything is fine, except (!) the completion which phpstorm is usually kind enough to offer is missing. If I create the object myself though through "new Entity()" everything seems fine.
$foo = $this->getDoctrine()->getRepository(Building::class)->find($id);
$bar = new Building();
$foo->getType()->.... //no type hinting
$bar->getType()->getName() // full type hinting
The weird thing is that the type of $foo seems to be PROXY\__CG__\AppBundle\Entity\Building
also, if I type it by hand, I get the phpStorm yellow warning that says the method doesn't exist. but it DOES work:
$foo->getType()->getName(); // returns real value
The thing is I have many properties of objects that are objects themselves with many other properties. So, the IDE help would be much appreciated.
I've scoured throughout the whole internet, not finding any solution.
Please sign in to leave a comment.
Also, forgot to mention... the forcing of:
doesn't change anything. Hovering over it, DOES say that the type is Building and "getType()" also DOES return "Type" but still - not suggestions by the IDE.
another weird thing is - if I fetch ALL objects as an array (findAll) and I foreach it, I get full type hinting as well. Obviously in any case it works, just not in the one i need it to :)