Skip to content

Warn about possible access to typed property before initialization #2984

@Lctrs

Description

@Lctrs

Feature request

New typed properties (even nullable ones) in PHP 7.4 don't get null assigned as a default value, they are in a new uninitialized state. Trying to access an uninitialized property will raise a runtime error "Typed property Foo::$bar must not be accessed before initialization".

Could be nice if code like this one could trigger an error about it.

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