Skip to content

Incorrect behavior of ClassPropertyAssignToConstructorPromotionRector #7751

@cwang22

Description

@cwang22

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/50e42109-9747-458b-bbad-cf105d3dc1d3

<?php

class Test
{
    public $a;

    public function __construct(string $a = null)
    {
        $this->a = $a;
    }
}

Responsible rules

  • ClassPropertyAssignToConstructorPromotionRector

Expected Behavior

either skip it or make the string type nullable so it not causing an error

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions