github lkrms/pretty-php v0.4.16

latest releases: v0.4.75, v0.4.74, v0.4.73...
15 months ago

Added

  • Preserve newline after throw
  • Add optional depth-first import sort order (available via --sort-imports-by)
  • Make heredoc indentation configurable via --heredoc-indent
  • Add --operators-first and --operators-last flags (CLI only)
  • Apply strict PSR-12 <?php declare... formatting and heredoc indentation when --psr12 is given (CLI only)

Changed

  • Don't apply hanging indentation in unambiguous single-expression contexts
  • Improve comment formatting
    • Normalise whitespace at the beginning and end of one-line C-style and docblock comments
    • Reindent text in multi-line comments to maintain original alignment
    • Expand leading tabs in comments to spaces (and unexpand leading spaces to tabs if using tabs for indentation)
    • Only treat comments indented by at least one space (relative to code in the same context) as continuations of comments beside code
    • Improve comment placement in switch structures
  • Refactor align-lists
    • Improve consistency by removing complex eligibility checks and problematic enforcement of newlines between items
    • Propagate alignment to adjacent code recursively and unconditionally, allowing structures like:
      <?php
      [':', [$a,
             $b, $c], [$d, $e,
                       $f], [$g,
                             $h, $i]];
  • Apply magic commas to list and other destructuring constructs, not just arrays and argument lists
  • Expand WordPress preset
  • Optimize for improved performance (in a 200-file batch test, v0.4.16 is 17% faster than with v0.4.15)

Removed

  • Remove one-line-arguments from available rules
  • Remove --disable indent-heredocs (replaced with --heredoc-indent none)

Fixed

  • Detect more unary contexts
  • Refactor block detection to fix alignment anomalies when PHP and markup are mixed

Don't miss a new pretty-php release

NewReleases is sending notifications on new releases.