Skip to content

ReadOnlyPropertyRector misses to add "readonly" for property with default value #9822

Description

@staabm

Bug Report

A property with a redundant default value does not get "readonly" treatment.

as soon as I remove = null default from the property, the "readonly" is properly added, see https://getrector.com/demo/3648f53a-26e7-422d-9d24-57cd6c85ba5a
(the = null is redundant, because the property is always overwritten in __construct)

Minimal PHP Code Causing Issue

https://getrector.com/demo/31124e18-e32b-41b3-8f12-87538e524872

Expected Behaviour

I am not sure its a bug in ReadOnlyPropertyRector. maybe rector should remove the redundant =null itself, so the other rules will start working as expected

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