PHP 8 Annotations bug?
Author: TimurFlushCreated Dec 9, 2020Updated Dec 29, 2020
Hello!
My stack: php: 8.0.0 symfony: 5.2 doctrine/orm: 2.8.1 doctrine/doctrine-bundle: 2.2.2
I have the next entitity:

I try to request a user by his login through the repository
return new Response(
$this->userRepository->findOneBy(['login' => 'someLogin'])->getLogin()
);and catch the next error:

This is due to the fact that the Doctrine annotation parser tries to go through all the properties of the annotation @ORM\Id (see the first screenshot). And since they don't exist, the foreach loop passes null and I catch this error.
To confirm my words, I attach screenshots from the xdebug:
Doctrine\Common\Annotations\CachedReader::getPropertyAnnotation()

Doctrine\Common\Annotations\CachedReader::getPropertyAnnotations()

Source: doctrine/annotations