Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony Route annotations are broken by Rector DEAD_CODE #4573

Closed
dameert opened this issue Nov 10, 2020 · 3 comments
Closed

Symfony Route annotations are broken by Rector DEAD_CODE #4573

dameert opened this issue Nov 10, 2020 · 3 comments

Comments

@dameert
Copy link
Contributor

dameert commented Nov 10, 2020

Bug Report

Subject Details
Rector version Rector dev-master@4764fd1
Installed as composer dependency

Rector "DEAD_CODE" changes Symfony Route annotations defaults incorrectly. defaults={"_format": "json"} becomes defaults={"_format"="json"}.

Minimal PHP Code Causing Issue

<?php
namespace App;

use Symfony\Component\Routing\Annotation\Route;

class Controller
{
    /**
     * @Route("/route/{view}.{_format}", name="views.test", defaults={"_format": "json"}, methods={"POST"})
     */
    public function updateAction()
    {
        return 'oops';
    }
}

https://getrector.org/demo/8d9faf4a-1729-4c34-8d56-6adf9cc63eaf#result

Expected Behaviour

Rector DEAD_CODE should not change the : (including space) to = in Route annotations.

@dameert
Copy link
Contributor Author

dameert commented Nov 10, 2020

Might be related to #3932 however the change made is different. I am eager to find a solution, but am not sure where to start looking for these annotation updates using the DEAD_CODE set.

@TomasVotruba
Copy link
Member

TomasVotruba commented Nov 10, 2020

Hi,

this is well known problem. The PHP code (without docblocks) has php-parser, that is handling its format to its best. There is issue there, that was only solved in version 3

The annotation don't have such a tool. Making such a tool requires to hugely modify phpstan/php-doc-parser, which might take months of work. This will be solved in PHP 8 with attributes, but we're not there yet. Saying that, there are made few assumptions to make php doc changes work.

What real issue this causes aparat different syntax?

@TomasVotruba
Copy link
Member

Sub-problem of #4334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants