rector icon indicating copy to clipboard operation
rector copied to clipboard

[Symfony] RemoveDefaultGetBlockPrefixRector remove block even is extending another class

Open lyrixx opened this issue 3 years ago • 3 comments

Bug Report

Subject Details
Rector version Rector 0.13.10

Minimal PHP Code Causing Issue

https://getrector.org/demo/845e536a-09f7-4566-9d10-194e33ab447c

I don't know why the demo does't fix the code, but in my project it does

Expected Behaviour

It must not remove the block prefix


I guess the issue is here

Because a type always extends AbstractType.

lyrixx avatar Aug 05 '22 16:08 lyrixx

Thank you for your report and demo link!

Could you send a failing test fixture in a pull-request to RemoveDefaultGetBlockPrefixRectorTest, so we have it covered in Rector?

TomasVotruba avatar Aug 05 '22 16:08 TomasVotruba

I added this fixtures, but it works (I means the test is OK)

But In my project, the method is removed

<?php

namespace Rector\Symfony\Tests\Rector\ClassMethod\RemoveDefaultGetBlockPrefixRector\Fixture;

use Symfony\Component\Form\ChoiceType;

class IconType extends ChoiceType
{
    public function getBlockPrefix()
    {
        return 'icon';
    }
}

?>
-----
<?php

namespace Rector\Symfony\Tests\Rector\ClassMethod\RemoveDefaultGetBlockPrefixRector\Fixture;

use Symfony\Component\Form\ChoiceType;

class IconType extends ChoiceType
{
    public function getBlockPrefix()
    {
        return 'icon';
    }
}

?>

lyrixx avatar Aug 05 '22 16:08 lyrixx

Found: https://github.com/rectorphp/rector-symfony/pull/212

lyrixx avatar Aug 05 '22 16:08 lyrixx

Thank you for the test fixture :+1: I'm looking into it

TomasVotruba avatar Aug 17 '22 13:08 TomasVotruba