Skip to content

PHP 8 Annotations bug? #388

@TimurFlush

Description

@TimurFlush

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:
entity

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:
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()
xdeb1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions