Skip to content

[DeadCode] Skip RemoveAlwaysTrueIfConditionRector on PHP + HTML files - #8895

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
tv-skip-inline-html-always-true-if
Closed

TomasVotruba wants to merge 1 commit into
mainfrom
tv-skip-inline-html-always-true-if

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

When an always-true if lives in a file that mixes PHP and inline HTML, unwrapping its statements drops the close-tag transition and prints invalid PHP - the inline HTML ends up emitted inside PHP mode.

<?php if (true) { ?>
<div>always</div>
<?php }

was rewritten to the broken:

<?php <div>always</div>

Reuse the file-level containsHTML() guard, matching the former HTMLAverseRectorInterface behavior. Added a skip fixture.

Unwrapping an always-true if in a file with inline HTML drops the close-tag transition and prints invalid PHP. Reuse the file-level containsHTML() guard, matching the former HTMLAverseRectorInterface behavior.
@TomasVotruba
TomasVotruba force-pushed the tv-skip-inline-html-always-true-if branch from 79ff8a6 to 82f11ab Compare October 30, 2026 13:00
@TomasVotruba TomasVotruba changed the title [DeadCode] Skip RemoveAlwaysTrueIfConditionRector on inline HTML stmts [DeadCode] Skip RemoveAlwaysTrueIfConditionRector on PHP + HTML files Oct 30, 2026
@samsonasik

Copy link
Copy Markdown
Member

it seems already covered at PR:

Let's closing 👍

@samsonasik samsonasik closed this Oct 30, 2026
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