Skip to content

RemoveAlwaysTrueIfConditionRector breaks inline if statements in *.phtml files. #9949

Closed
rectorphp/rector-src
#8896

Description

@mvvelde

Bug Report

Subject Details
Rector version 2.7.0

Minimal PHP Code Causing Issue

\Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector breaks inline if statements in *.phtml files.

template.phtml:

<?php

declare(strict_types=1);

$alwaysTrue = true;

if ($alwaysTrue): ?>
    <span>Always visible</span>
<?php endif;

Running $ vendor/bin/rector template.phtml --only RemoveAlwaysTrueIfConditionRector results in the following diff.

 <?php
 
 declare(strict_types=1);
 
 $alwaysTrue = true;
 
-if ($alwaysTrue): ?>
     <span>Always visible</span>
-<?php endif;

Expected Behaviour

 <?php
 
 declare(strict_types=1);
 
 $alwaysTrue = true;
 
-if ($alwaysTrue): ?>
+?>
     <span>Always visible</span>
-<?php endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions