Skip to content

Incorrect behavior of ReadOnlyClassRector #7734

@mvhirsch

Description

@mvhirsch

Bug Report

Subject Details
Rector version v0.15.7+
Installed as composer dependency

Minimal PHP Code Causing Issue

Tested with 0.15.7, 0.15.10 (different projects) and online.

See https://getrector.com/demo/bfd6ec7c-7c61-46b0-8915-967c4cc0b646

<?php

#[Route('/statistiken/bundesland', name: AdminRoutes::STATISTICS_IMMOBILIE_BUNDESLAND)]
final class BundeslandStatisticsController
{
    public function __construct(
        private readonly Responder $responder,
        private readonly RepositoryInterface $repository,
    ) {
    }
}

As you can see it inlines my annotation and class-spec.

Responsible rules

  • ReadOnlyClassRector

Expected Behavior

Rector should add readonly to this class, but respect the newline before final class.

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