Indentation issue inside php tags on html/php
Description
Part of the PHP code changed while this wasn't expected: (it was indented, it lost indentation).
Command:
html-beautify -r -t --templating=php --end-with-newline=true -b expand "file"
Input
The code looked like this before beautification:
<?php $this->load->view('js_init/users/js_users');
if ($users->num_rows() === 0):
if ($_POST)
{
echo "<p><i><?php echo lang('tni_user_not_found'); ?></i></p>";
}
else
{
echo "<p><i><?php echo lang('tni_user_search_empty'); ?></i></p>";
}
else: ?>
<p>aa</p>
<?php endif; ?>
Expected Output
The code should have looked like this after beautification:
<?php $this->load->view('js_init/users/js_users');
if ($users->num_rows() === 0):
if ($_POST)
{
echo "<p><i><?php echo lang('tni_user_not_found'); ?></i></p>";
}
else
{
echo "<p><i><?php echo lang('tni_user_search_empty'); ?></i></p>";
}
else: ?>
<p>aa</p>
<?php endif; ?>
Actual Output
The code actually looked like this after beautification:
<?php $this->load->view('js_init/users/js_users');
if ($users->num_rows() === 0):
if ($_POST)
{
echo "<p><i><?php echo lang('tni_user_not_found'); ?></i></p>";
}
else
{
echo "<p><i><?php echo lang('tni_user_search_empty'); ?></i></p>";
}
else: ?>
<p>aa</p>
<?php endif; ?>
Steps to Reproduce
Environment
OS: linux debian 11
Settings
default + command:
html-beautify -r -t --templating=php --end-with-newline=true -b expand "file"
I just saw that there is such a terrible <?php inside the text of the echo.
That is the culprit. If I remove it, then there is no indentation issue.
So the problem is linked to the presence of some <?php ?> nested inside a another <?php ?> in this case it is hidden in a PHP string