Skip to content

Uninitialized redeclared property on a class that parent initializes #9864

@jordisala1991

Description

@jordisala1991

Bug report

When redeclaring a property that is present on a parent class PHPStan complains that the property is not initialized in the __construct(), even if it is present and initialized on the parent __construct() (and the child class calls parent::__construct()).

This error cannot be avoided since trying to reassign in the snipped provided will make PHP unhappy because it is a readonly property and can only be assigned once.

In case anyone wonders, I need to redeclare the property because on child class I want to add some doctrine attributes (ORM mapping)

Code snippet that reproduces the problem

https://phpstan.org/r/03e5be2a-69a2-493d-a67c-5f3069961815

Expected output

No issues

Did PHPStan help you today? Did it make you happy in any way?

PHPStan helps me and my team everyday ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions