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

Add failing test fixture for RemoveDeadReturnRector #2909

Closed
wants to merge 1 commit into from

Conversation

kkmuffme
Copy link
Contributor

@kkmuffme kkmuffme commented Sep 4, 2022

Failing Test for RemoveDeadReturnRector

Based on https://getrector.org/demo/38caa690-bf47-405c-af7c-bad1e6d166aa

Exactly the same issue also for \Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector::class - do you need a separate test PR for it? (bc it's really exactly the same test code)

# Failing Test for RemoveDeadReturnRector

Based on https://getrector.org/demo/38caa690-bf47-405c-af7c-bad1e6d166aa

Exactly the same issue also for \Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector::class - do you need a separate test PR for it? (bc it's really exactly the same test code)
@samsonasik
Copy link
Member

these kind of mix html+php in function should just be skipped, but if you have better solution, feel free to provide a patch

@kkmuffme
Copy link
Contributor Author

kkmuffme commented Sep 5, 2022

What's the reason those should be skipped? Bc it's complex to auto-fix those?

EDIT: even if they should be skipped, the rule should skip it by itself.

@samsonasik
Copy link
Member

Rector is using nikic/php-parser, which replacing html+php may overap the index.

Still, feel free to provide patch if you found a solution, otherwise, you can use $rectorConfig->skip() option to skip the rule.

@TomasVotruba
Copy link
Member

I'll see if Rector know something about the context here, but won't give much home.

In general PHP + HTML are problematic because of switching context.

@TomasVotruba TomasVotruba self-assigned this Sep 5, 2022
@TomasVotruba
Copy link
Member

TomasVotruba commented Sep 5, 2022

So it seems the printer removes <?php and creates invalid code 🤔

Now we have to find out, if that's Rector printer on native php-parser printer :)

@TomasVotruba
Copy link
Member

TomasVotruba commented Sep 5, 2022

So it seems it's the way php-parser prints the stmts: nikic/PHP-Parser#884

It must be fixed there first to propagate fix here.

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

Successfully merging this pull request may close these issues.

3 participants