Skip to content

[symfony] Incorrect behavior of InlineClassRoutePrefixRector #9250

@hildebro

Description

@hildebro

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/1b49f49d-810a-4e6d-b7a9-7903a2fde5e9

<?php

use Symfony\Component\Routing\Attribute\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;


#[Route(
    '/admin',
    name: 'admin.',
    defaults: [
        '_require_identity' => 'xxx',
        '_exception_handle' => 'xxx',
        '_roles' => ['xxx'],
    ]
)]
class SomeController extends AbstractController
{
    #[Route(
        '/actions/demo',
        name: 'actions.demo',
        defaults: [
            '_roles' => ['yyy'],
        ],
        methods: ['POST']
    )]
    public function actionsDemo()
    {
        return $this->json([]);
    }
    
    #[Route(
        '/actions/demo2',
        name: 'actions.demo2',
        defaults: [
            '_roles' => ['yyy2'],
        ],
        methods: ['POST']
    )]
    public function actionsDemoTwo()
    {
        return $this->json([]);
    }    
}

Responsible rules

  • InlineClassRoutePrefixRector

Expected Behavior

  1. The rule shouldn't remove defaults from the class. The name implies it only deals with prefixes.
  2. The rule shouldn't remove the blank line between the functions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions