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

Incorrect behavior of AnnotationToAttributeRector #6928

Closed
marcosemplici opened this issue Jan 11, 2022 · 6 comments · Fixed by rectorphp/rector-src#1659
Closed

Incorrect behavior of AnnotationToAttributeRector #6928

marcosemplici opened this issue Jan 11, 2022 · 6 comments · Fixed by rectorphp/rector-src#1659
Labels

Comments

@marcosemplici
Copy link

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.org/demo/1ec72cab-b010-69f0-9785-0f4103e3217a

<?php
use ApiPlatform\Core\Annotation\ApiFilter;

/**
 * @ApiFilter(SearchFilter::class,
 *     properties={
 *     "id": "exact",
 *     ActivationRequest::FIRSTNAME : "ipartial",
 * })
 */
class ActivationRequest
{
    public const FIRSTNAME ='firstName';
}

Responsible rules

  • AnnotationToAttributeRector

Expected Behavior

@marcosemplici
Copy link
Author

RECTOR CHANGED:

use ApiPlatform\Core\Annotation\ApiFilter;

#[ApiFilter(SearchFilter::class, properties: ['id' => 'exact', 0 => ActivationRequest::FIRSTNAME])]
class ActivationRequest
{
    public const FIRSTNAME ='firstName';
}

EXPECTED:

use ApiPlatform\Core\Annotation\ApiFilter;

#[ApiFilter(SearchFilter::class, properties: ['id' => 'exact',  ActivationRequest::FIRSTNAME => 'ipartial'])]
class ActivationRequest
{
    public const FIRSTNAME ='firstName';
}

@TomasVotruba
Copy link
Member

TomasVotruba commented Jan 11, 2022

Thanks for reporting. Could you check this fix if it fits your use case?
rectorphp/rector-src#1659

@marcosemplici
Copy link
Author

Yes it fixs. But there's similar use case...
https://getrector.org/demo/1ec72f1d-35ed-671c-8788-a18acc9c9cfc

@TomasVotruba
Copy link
Member

TomasVotruba commented Jan 11, 2022

I see. Could you add test fixture with that code in the /Fixture directory?
You can copy this one, just replace class name and nested items: https://github.com/rectorphp/rector-src/pull/1659/files#diff-5a4601bb83345d7f48c1acf8b28e5906e284487015c6ff891b21a8724ae03cbb

@Jean85
Copy link
Contributor

Jean85 commented Jan 11, 2022

I tried to do it in rectorphp/rector-src#1661

@samsonasik
Copy link
Member

I am closing it as resolved at rectorphp/rector-src#1661

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

Successfully merging a pull request may close this issue.

4 participants