phpstormphpstorm-2017.2

Disable auto indentation for embedded PHP code


In my settings I have 4 spaces to indent PHP code and 2 for HTML code My templates have .php extension

When I trying to indent a PHP code with 2 spaces it forces 4 spaces. "Backspace" key does not work at all

<?php foreach($array as $k => $v) { ?>
  <a class="btn btn-default" href="<?php echo $this->url("path"); ?>">
      <?php echo $this->text('Text'); ?> <---MOVE this 2 spaces left
  </a>
<?php } ?>

How to allow custom indentation for such cases?


Solution

  • That's a known issue: https://youtrack.jetbrains.com/issue/WI-32401. Here's a code piece that illustrates this a little bit better:

    <?php foreach ($array as $k => $v) { ?>
      <a class="btn btn-default" href="<?php echo $this->url("path"); ?>">
          <?php echo $this->text('Text'); ?> <---MOVE this 2 spaces left
        <div>
          <div>
              <?php echo $this->text('Text'); ?>
              <?php
              echo $this->text('Text');
              if ($a > 1) {
                  echo 1;
              }
              ?>
          </div>
        </div>
      </a>
    <?php } ?>
    

    Feel free to vote for/comment it to follow the updates of the issue