Skip to content

RemoveDefaultValueFromAssignedPropertyRector does not work with nested conditional assignments #9957

Closed
rectorphp/rector-src
#8915

Description

@raphaelincert

Bug Report

Subject Details
Rector version 2.8.3

Hi,

the rule RemoveDefaultValueFromAssignedPropertyRector does not work with nested conditional assignments. The default value should only be removed if it is guaranteed that the property will be assigned a value in the constructor. The current change results in the error:
Fatal error: Uncaught Error: Typed property DemoFile::$a must not be accessed before initialization in

Best regards

Minimal PHP Code Causing Issue

https://getrector.com/demo/7ae45f9c-e1c9-43a0-91e8-2ac7070fb511

Expected Behaviour

No change

Activity

  1. TomasVotruba commented on Nov 3, 2026

    @TomasVotruba
    Member

    Thank you for reporting

    Fixed in rectorphp/rector-src#8915

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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