You will need to typehint for the IDE to know what type of model the repository reutrns.
The getRepository
method returns a Doctrine\ORM\EntityRepository
, which, when calling findAll()
has no idea what type of entity it is you are trying to find (while find all returns a array
).
/** @var \Entity\ServiceType[] $all */
$all = $entityManager->getRepository('\Entity\ServiceType')->findAll();
Should do the trick.
Edit:
Apparently not all IDE's support this.
If that is the case, you can create a typehint comment inside the foreach loop for the $value
variant instead:
/** @var \Entity\ServiceType[] $all */
$all = $entityManager->getRepository('\Entity\ServiceType')->findAll();
foreach($all as $value) {
/** @var \Entity\ServiceType $value */
$options[$value->getId()] = $value->getServiceType();
}
First hint for any of the devs in the team that uses the Jetbrains IDEs and the second for the rest!