plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

Converting short php tags

Open bohrasankalp opened this issue 4 years ago • 4 comments

I find few code having shorted PHP tag <? ?> . Is there any way in the configuration if these tags get converted into whole long tag like <?php ?>? This is plugin has abrupt behavior for the shorter tags. Either blank ?> are appended to code since starting short tag is not parsed.

Second point whole the PHP code inside PHP tags remove the tab indent make it in the same line with PHP tag? Any configuration changes for that as well. THough tab-indent is enabled in .prettierrc.

bohrasankalp avatar Mar 20 '21 10:03 bohrasankalp

Hi @bohrasankalp Can you share some concrete examples?

czosel avatar Mar 21 '21 07:03 czosel

I have been just trying my years old code, probably from 2011. Just for reference this particular file is failing

<?php
$MinMumRates = $oCommFun->GetHomePageRatesTable();
if(count($MinMumRates) > 0) { ?>
  <div class="leftside">
    <h1><img src="images/bullet.png" width="14" height="14" alt="" /> Reduced Rates</h1>
    <div style="background:#f7f7f7; padding:0px 12px 7px 12px;">
      <table width="283" border="0" cellpadding="0" cellspacing="0" style="padding-top:2px;">
        <?php for($d=0; $d<count($MinMumRates); $d++)
        {
        $Details = $oCommFun->GetMinimumRates($MinMumRates[$d]['location_id'], $MinMumRates[$d]['product_id']);
        if(count($Details) > 0) {
          $htmlLink = $CONFIG['host']."rates.php?selcallingfrom=usa&selcallingto=".$Details[0]['location_name'];
          $buyNow = $CONFIG['host']."order.php?product_id=".$MinMumRates[$d]['product_id'];
    ?>
        <tr class="border_bottom">
          <td width="19" align="left" class="border_bottom"><img src="images/reduce_rates_bullets.jpg" width="10" height="10" /></td>
          <td class="border_bottom" width="180" height="26" align="left" style="font-size:12px;"><a href="<?=$htmlLink?>" style="font-family:Arial, Helvetica, sans-serif; text-decoration:none;color:#434343;">
            <?=$Details[0]['location_name'];?>
            </a></td>
          <td width="45" class="border_bottom"><? if($Details[0]['location_name'] == 'India - Mobile') {?>
            <a href="<?=$htmlLink?>" style="font-family:Arial, Helvetica, sans-serif; color:#434343; font-size:12px; text-decoration:none"><?php echo "1.66";?> &cent;</a>
            <? }else {?>
            <a href="<?=$htmlLink?>" style="font-family:Arial, Helvetica, sans-serif; color:#434343; font-size:12px; text-decoration:none">
            <?=$Details[0]['minprice'];?>
            &cent;</a>
            <? } ?>
          </td>
          <td width="39" align="right" class="border_bottom"><a href="<?=$buyNow?>" style="font-family:Arial, Helvetica, sans-serif; text-decoration:none; font-size:12px; color:#d21018; font-weight:bold;">Buy</a></td>
        </tr>
        <? }}?>
      </table>
    </div>
  </div>
<? }?>

bohrasankalp avatar Mar 25 '21 17:03 bohrasankalp

@czosel any updates?

bohrasankalp avatar Apr 07 '21 13:04 bohrasankalp

It is unsafe for AST

alexander-akait avatar Apr 07 '21 13:04 alexander-akait