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

AnnotationToAttribute doesn't work if there s an existing attribute above annotations #7453

Closed
bendavies opened this issue Sep 5, 2022 · 9 comments
Labels

Comments

@bendavies
Copy link
Contributor

bendavies commented Sep 5, 2022

Bug Report

Subject Details
Rector version 0.14.2

When using DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, entities with attributes above annotations will fail to transform the annotationa to attributes.

If the ApiResource attributes are removed, then the Doctrine annotations are correctly converted.

Minimal PHP Code Causing Issue

<?php

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use Doctrine\ORM\Mapping as ORM;

#[ApiResource(
    operations: [
        new Get(),
        new GetCollection(),
    ],
    normalizationContext: ['groups' => ['policy-notice:read']],
)]
/**
 * @ORM\Entity()
 * @ORM\Table(name="policies_notices")
 */
class PolicyNotice
{}

Expected Behaviour

all the Annotations become Attributes!

@bendavies bendavies added the bug label Sep 5, 2022
@TomasVotruba
Copy link
Member

Possibly related nikic/PHP-Parser#201

@TomasVotruba
Copy link
Member

We'll need an isolated failing demo link from: http://getrector.org/demo, from that create failing test case pull-request.

@bendavies
Copy link
Contributor Author

@TomasVotruba
Copy link
Member

Seems like the way php-parser resolve this: nikic/PHP-Parser#887

@TomasVotruba
Copy link
Member

We discussed it and the way is to flip those with e.g. fixer.

See nikic/PHP-Parser#887 (comment)

@bendavies
Copy link
Contributor Author

related previous discussion
#7225

@TomasVotruba
Copy link
Member

TomasVotruba commented Sep 6, 2022

@bendavies That's why the PHP CS Fixer is needed to handle these situations. It can be only done with token scope.

@bendavies
Copy link
Contributor Author

bendavies commented Sep 6, 2022

indeed, but note your last comment on that issue (granted it might be a slightly different issue)

So there is no need for such rule.

but now we think there is :)

@TomasVotruba
Copy link
Member

It was a different scope indeed.

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

No branches or pull requests

2 participants