Skip to content

Releases: lkrms/pretty-php

v0.4.89

23 Jan 13:52
v0.4.89
83966b9
Compare
Choose a tag to compare

Changed

  • Check if the last statement exited a switch case when indenting comments
  • Don't add a space between fn and & in arrow functions that return a value by reference
  • Improve formatting of empty statements after open tags
  • Improve empty switch indentation

Fixed

  • Fix issue where declare() statements with unenclosed bodies are not formatted correctly
  • Fix regression in v0.4.86 where "magic" commas may be ignored when preserve-one-line is enabled

v0.4.88

21 Jan 02:47
v0.4.88
314f291
Compare
Choose a tag to compare

Changed

  • Remove binary prefixes (e.g. b in b"foo$bar") from all strings, not just constant strings
  • Remove double quotes and leading whitespace from heredoc and nowdoc labels (e.g. <<< "EOF" becomes <<<EOF)
  • Improve declaration spacing
    • Add blank lines after loosely-spaced declarations so comments cannot start on the next line
    • Allow for comments between DocBlocks and subsequent declarations when checking input spacing and suppressing blank lines
    • Don't always add a blank line between declarations separated by comments other than DocBlocks
  • Improve readability of anonymous functions with lexical variables by adding newlines before:
    • parameter lists that break over multiple lines
    • lexical variable lists that break over multiple lines

Fixed

  • Fix issue where nowdocs with whitespace before the label may not be formatted correctly (reported in #195)
  • Fix issue where newlines are suppressed before heredocs at the start of statements when --psr12 is given
  • Fix issue where heredocs with a b prefix are not formatted correctly
  • Fix issue where code needs to be formatted twice for correct placement of brackets in some expressions
  • Fix issue where grouped imports like use A\B\{C\D, function b\c, const D}; trigger an exception
  • Fix issue where exceptions like Deprecated: The (real) cast is deprecated, use (float) instead are thrown on PHP 7.4
  • Fix issue where binary strings may trigger an exception on PHP 7.4
  • Fix inconsistent output when input uses multiple line endings

Security

  • Fail with an exception if pretty-php is running as root

v0.4.87

13 Jan 05:20
v0.4.87
5af7575
Compare
Choose a tag to compare

Changed

  • Don't place coalesce operators (??) at the end of the line when --operators-last is given

Fixed

  • Fix issue where newlines are not suppressed inside parentheses in DNF types

  • Fix issue where code from adjacent scopes may have the same indentation

    <?php
    
    // Before:
    $foo = bar('foo',
        'bar')
        ->baz();
    
    function ($foo,
        $bar) {
        baz();
    };
    
    // After:
    $foo = bar('foo',
            'bar')
        ->baz();
    
    function ($foo,
            $bar) {
        baz();
    };
  • Fix issue where only the last constructor in the document with a promoted parameter is formatted correctly

  • Fix issue where lists with leading delimiters may not be aligned when align-lists is enabled

v0.4.86

08 Jan 08:35
v0.4.86
af5e85f
Compare
Choose a tag to compare

A lot of refactoring has gone into this release, so there may be changes not picked up in testing or not mentioned here.

If you think this version of pretty-php does something worse, not better, please open an issue or start a discussion.

Added

  • Add --no-problems option to CLI command for better control of output verbosity

Changed

  • Improve formatting of for loops with expressions that break over multiple lines
  • When align-data is enabled, don't align = in parameter lists with no leading newline unless strict-lists or align-lists are also enabled
  • When the symfony preset is enabled, don't suppress newlines in parameter lists with no promoted constructor parameters if they have a trailing comma

Fixed

  • Fix issue where newlines are collapsed between close braces and subsequent increment or decrement operators
  • Fix issue where blank lines before and after comments are not preserved in alternative syntax constructs
  • Fix issue where unnecessary whitespace is not removed from empty lines in nested heredocs
  • Fix inconsistent formatting of lists with trailing AND leading commas
  • Fix blank-before-return issue where blank lines are not added before yield statements in alternative syntax constructs
  • Fix align-lists issue where alternative syntax constructs may not be indented correctly
  • Fix align-data issue where assignments in alternative syntax constructs are not aligned

v0.4.85

03 Jan 03:40
v0.4.85
eac9778
Compare
Choose a tag to compare

Changed

  • Refactor hanging indentation to improve output quality and consistency, especially when formatting complex expressions that break over multiple lines
    • Vary indentation to reflect operator precedence where possible
    • Suppress the first level of hanging indentation in more single-expression contexts
  • Format more lists when strict-lists or align-lists are enabled:
    • import lists (e.g. use Foo\Bar, Foo\Baz)
    • import list groups (e.g. use Foo\{Bar, Baz})
    • trait insertion lists
    • insteadof lists when inserting traits
    • property and constant declaration lists
    • static and global variable lists
  • Add newlines between comma-delimited property and constant declarations

Fixed

  • Fix multiple issues with runaway mid-expression indentation
  • Fix issue where anonymous classes that implement multiple interfaces may not be formatted correctly in list contexts

v0.4.84

26 Dec 03:40
v0.4.84
49542d2
Compare
Choose a tag to compare

Changed

  • Don't collapse DocBlocks with @mixin or @param-* tags

Fixed

  • Fix issue where switch cases with expressions that contain ternary operators or closures with native return types may be formatted incorrectly

v0.4.83

23 Dec 06:38
v0.4.83
1c32355
Compare
Choose a tag to compare

Changed

  • Rewrite align-data rule (enabled via --enable align-data or --preset wordpress) to improve output stability and performance
  • When align-data is enabled, only align consecutive assignment operators, => delimiters in array syntax, and => delimiters in match expressions

Removed

  • In align-data, don't align arbitrary comma-delimited expressions across multiple columns

    If removal of this experimental feature affects you, please let me know by starting a discussion on GitHub.

  • In align-data, don't align delimiters after case and default in consecutive one-line switch cases

Fixed

  • Fix blank-before-return issue where blank lines may be added before yield or yield from in non-statement contexts

v0.4.82

20 Dec 00:26
v0.4.82
fed8888
Compare
Choose a tag to compare

Changed

  • Don't zero-pad integer literals that use hexadecimal or binary notation and have an odd number of digits
  • In expressions with newlines adjacent to boolean operators, collapse newlines between brackets on their own line
  • In chained ternary expressions, limit the scope of indentation and alignment changes to better reflect operator precedence and associativity
  • When align-ternary is enabled and ternary operators are aligned with an expression that breaks over multiple lines, align with the first token on the previous line (for consistency with align-comments and align-fn)

Fixed

  • Refactor unenclosed control structure body handling to fix multiple issues where they are not formatted correctly
  • Fix issue where comments after labels may be moved incorrectly
  • Fix issue where ternary expressions are incorrectly aligned across logical operator boundaries
  • Fix issue where lines that start with a T_END_HEREDOC may trigger incorrect alignment of subsequent tokens

v0.4.81

04 Dec 09:31
v0.4.81
daa3248
Compare
Choose a tag to compare

Changed

  • Ignore placement of close brackets when strict-expressions and semi-strict-expressions check for control structure expressions that break over multiple lines

Fixed

  • Fix issue where warnings about invalid --enable or --disable rules in config files are printed twice

v0.4.80

29 Nov 09:10
v0.4.80
0b5fd65
Compare
Choose a tag to compare

Changed

  • Add optional formatting rule semi-strict-expressions

    Unlike strict-expressions, this rule only moves control structure expressions to a new line if there are line breaks between siblings in the expression. If line breaks only appear between bracketed sub-expressions, the start of the expression is left on the same line as its open bracket.

  • Move => to the other side of a comment if necessary for correct placement
  • Improve input indentation handling
  • Improve performance