Thanks to visit codestin.com
Credit goes to github.com

Skip to content

'Cannot access uninitialized non-nullable property' on symfony/var-exporter 6.3.9 #52839

Closed as not planned
@stephanvierkant

Description

@stephanvierkant

Symfony version(s) affected

6.3.9, 6.4.0

Description

As of Symfony/var-exporter 6.3.9 I've got this error message on multiple places in my application:

Cannot access uninitialized non-nullable property App\Entity\User::$notifications by reference

It happens when I get an Organization from Doctrine.

My entity:

#[\ApiPlatform\Metadata\ApiResource(
    // ...
)]
#[\Doctrine\ORM\Mapping\Entity(UserRepository::class)]
class User
{
    #[ManyToOne(Organisation::class, cascade: ['persist'], inversedBy: 'users')]
    #[Gedmo\Versioned]
    private ?Organisation $organisation = null;

    #[OneToMany('user', targetEntity: \App\Entity\User\Notification::class)]
    private Collection $notifications;
    public function __construct()
    {
        $this->notifications = new ArrayCollection();
    }
}

How to reproduce

I'll create a reproducer if necessary, but before I do I'd like to hear some feedback. Maybe it's a simple mistake I've made, or someone has some suggestions how to create a reproducer.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions