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

Document "hanging" vs "overhanging" indentation

Open lkrms opened this issue 2 years ago • 0 comments

A rough starting point:

.OH. is applied if:

  • the open bracket of the block is not followed by a newline, AND
  • either:
    • the block contains ,- or ;- delimited items, OR

    • the block forms part of a structure that continues, e.g.

      if ($block) {
          // continuation
      }
      
      1. Standard indentation is sufficient
      
      [
          ___, ___,
          ___, ___
      ]
      
      2. One level of hanging indentation is required
      
      [
          ___, ___
          .hh.___, ___,
          ___, ___
      ]
      
      3. One level of hanging indentation is sufficient
      
      [___, ___,
      .hh.___, ___]
      
      4. Two levels of hanging indentation are required
      
      [___, ___
      .hh..OH.___, ___,
      .hh.___, ___]
      
      5a. Two levels of hanging indentation are required per level of nesting
      
      [___, [___,
      .hh..OH..hh.___],
      .hh.___,[___, ___
      .hh..OH..hh..OH.___,
      .hh..OH..hh.___]]
      
      5b.
      
      [[[___
      .hh..OH..hh..OH..hh..OH.___,
      .hh..OH..hh..OH..hh.___],
      .hh..OH..hh.___],
      .hh.___]
      

lkrms avatar Jun 17 '23 07:06 lkrms