Skip to content

NewInInitializerRector creates bugs #9672

@VincentLanglet

Description

@VincentLanglet

Bug Report

The NewInInitializer rule is changing the property from non nullable to nullable
https://getrector.com/rule-detail/new-in-initializer-rector
This is a real issue when the property is used later.

With the exemple of the rule new SomeClass(null) will create bug when $this->logger is used ; while it worked before.

Subject Details
Rector version latest

Minimal PHP Code Causing Issue

https://getrector.com/demo/54bb158c-7a82-4d59-8fd2-c66eff068eef
See https://3v4l.org/VcW9g#v8.3.30

Expected Behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions