Skip to content

Fix PhpAstExtractor import removal in composer-based Symfony set - #1070

Merged
TomasVotruba merged 4 commits into
rectorphp:mainfrom
d-mitrofanov-v:fix/PhpAstExtractor-replaced-by-itself
Sep 23, 2026
Merged

TomasVotruba merged 4 commits into
rectorphp:mainfrom
d-mitrofanov-v:fix/PhpAstExtractor-replaced-by-itself

Conversation

@d-mitrofanov-v

Copy link
Copy Markdown
Contributor

The composer based Symfony set included a rename rule that mapped Symfony\Component\Translation\Extractor\PhpAstExtractor to itself. When Rector processed code using that class, it could remove the use import even though the class was still referenced

@TomasVotruba

Copy link
Copy Markdown
Member

Can you add validation to the rename itself to throw an exception if class name is the same?

@TomasVotruba

Copy link
Copy Markdown
Member

Also, it seems it should be corrected, not removed:

  • Deprecate PhpExtractor in favor of PhpAstExtractor

@d-mitrofanov-v

Copy link
Copy Markdown
Contributor Author

Thanks, fixed it. Now it should replace PhpExtractor with PhpAstExtractor. Also added test for that

@TomasVotruba

Copy link
Copy Markdown
Member

No need for test, this is a core rule.

@d-mitrofanov-v

Copy link
Copy Markdown
Contributor Author

Removed the test

@TomasVotruba

Copy link
Copy Markdown
Member

Thank you 👍

@TomasVotruba
TomasVotruba enabled auto-merge (squash) September 23, 2026 12:15
@TomasVotruba
TomasVotruba merged commit 19c0b38 into rectorphp:main Sep 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants