Skip to content

Releases: lkrms/pretty-php

v0.4.50

21 Jan 03:39
v0.4.50
3af4982
Compare
Choose a tag to compare

Fixed

  • Copy build tools to the repository to fix downstream packaging issues

v0.4.49

21 Jan 02:12
v0.4.49
0b7f8c0
Compare
Choose a tag to compare

Added

  • Add another --quiet level so a summary of changes can be printed without reporting every file replaced
  • Add colour to unified --diff output when the standard output is a TTY

Changed

  • Escape non-ASCII characters with Unicode's "blank" property
  • Improve validation of options loaded from configuration files
  • Improve --debug output
  • Add --log-progress so --debug need not be combined with --verbose to generate progress-log files

Fixed

  • Fix bugs related to empty directories and configuration files, e.g. where pretty-php falls backs to reading from STDIN when directories given on the command line yield no files to format

v0.4.48

11 Jan 10:09
v0.4.48
5607109
Compare
Choose a tag to compare

Added

  • Normalise integers and floats

    Before:

    <?php
    $decimal = [0, 1234567, 1_2_3, 12_34_56_7];
    $hex = [0x1, 0x000b, 0xfe0, 0X00_CA_FE_F0_0D];
    $octal = [00, 000_600, 0o755, 0O411];
    $binary = [0b1, 0b0011, 0B101];
    $float = [.14, 3., 03.00, 00.1400, 06.71E+083, 671.21e-4];

    After:

    <?php
    $decimal = [0, 1234567, 123, 1_234_567];
    $hex = [0x01, 0x0B, 0x0FE0, 0xCAFE_F00D];
    $octal = [0, 0600, 0755, 0411];
    $binary = [0b01, 0b11, 0b0101];
    $float = [0.14, 3.0, 3.0, 0.14, 6.71e83, 6.7121e-2];
  • Add --no-simplify-numbers option

  • Sign pretty-php.phar releases for improved PHIVE support

Fixed

  • Fix regression in [v0.4.47] where some Unicode sequences are escaped incorrectly, producing output like "🧑\u{200D}🚒" instead of '🧑‍🚒'
  • Fix issue where strings containing sequences like "\0002" (NUL followed by "2") are incorrectly normalised to "\02" (equivalent to "\x02")
  • Fix output validation issue where all tokens are truncated for comparison, not just comments

v0.4.47

08 Jan 23:48
v0.4.47
7aa6e22
Compare
Choose a tag to compare

Changed

  • Use \x{####} to escape UTF-8 characters with the Unicode Default_Ignorable_Code_Point property to improve code readability when working with invisible sequences, e.g. Unicode byte order marks

Fixed

  • Fix issue where escaped carriage returns ("\r") are not preserved in multiline strings
  • Fix issue where strings with invalid UTF-8 sequences trigger an exception

v0.4.46

29 Dec 05:44
v0.4.46
578e402
Compare
Choose a tag to compare

Changed

  • Remove align-lists from the laravel preset

  • Don't force newlines between boolean operators and negated expressions

    Before:

    <?php
    foo(bar() &&
        qux() &&
        quux() &&
        !(
            quuux() ||
            quuuux()
        ));

    After:

    <?php
    foo(bar() &&
        qux() &&
        quux() && !(
            quuux() ||
            quuuux()
        ));

Fixed

  • Fix sort-imports issue where traits inserted into enums are sorted in error

v0.4.45

22 Dec 07:00
v0.4.45
45b1c54
Compare
Choose a tag to compare

Fixed

  • Fix regression where disabled rules are ignored in strict PSR-12 mode

v0.4.44

21 Dec 15:14
v0.4.44
25fde31
Compare
Choose a tag to compare

Changed

  • Propagate line breaks after logical and bitwise operators to others of equal or lower precedence in the same statement

    <?php
    // Input
    foo(bar() ||
        baz() || qux() && quux() || quuux());
    
    // Output
    foo(bar() ||
        baz() ||
        qux() && quux() ||
        quuux());
  • Place comments with subsequent delimiters after the delimiters, demoting DocBlocks to standard C-style comments as a precaution

    Input:

    <?php
    [
        // comment
        0 => 'foo'
        ,1 => 'bar'
        // comment
        ,2 => 'baz'
    ];
    
    [
        /** DocBlock */
        0 => 'foo'
        ,1 => 'bar'
        /** invalid DocBlock */
        ,2 => 'baz'
    ];

    Previous output:

    <?php
    [
        // comment
        0 => 'foo',
        1 => 'bar'
            // comment
            , 2 => 'baz'
    ];
    
    [
        /** DocBlock */
        0 => 'foo',
        1 => 'bar'
            /** invalid DocBlock */, 2 => 'baz'
    ];

    Current output:

    <?php
    [
        // comment
        0 => 'foo',
        1 => 'bar',
        // comment
        2 => 'baz'
    ];
    
    [
        /** DocBlock */
        0 => 'foo',
        1 => 'bar',
        /* invalid DocBlock */
        2 => 'baz'
    ];
  • Preserve newlines before ??=, not after

  • Do not keep <?php...?> blocks on one line if they contain more than one statement

  • Improve indentation and alignment heuristics when HTML has embedded PHP

  • Stop looking for a configuration file when a .svn directory is found (.git and .hg directories already had this effect)

  • Rework exit codes for more granular feedback

  • Update usage information and JSON schema

Fixed

  • Fix issue where output is written to standard output when an explicit --output file is given
  • Don't print "Formatting 1 of 1: php://stdin" when reading TTY input

v0.4.43

09 Nov 00:29
v0.4.43
76d4466
Compare
Choose a tag to compare

Changed

  • Always move doc comments (/** ... */) to the next line
  • Don't add blank lines before multi-line doc comments or their C-style counterparts if they appear mid-statement
  • Collapse doc comments with one line of content to a single line (unless they appear to describe a file or are pinned to a declaration)
  • Remove empty doc comments

v0.4.42

26 Oct 23:50
v0.4.42
ff48e68
Compare
Choose a tag to compare

Added

  • Add (experimental) support for PHP 8.3

Fixed

  • Fix issue where CompileError exceptions thrown by the PHP 8.3 tokenizer are not caught

  • Fix ternary alignment issue when ?? appears in the first expression

    Before:

    <?php
    $foo = $bar
        ? $qux[$i] ?? $fallback
            : $quux;

    After:

    <?php
    $foo = $bar
        ? $qux[$i] ?? $fallback
        : $quux;
  • Fix issue where labels after close braces are not correctly identified

    Before:

    <?php
    if ($foo) {
        goto bar;
    }
    bar: qux();

    After:

    <?php
    if ($foo) {
        goto bar;
    }
    bar:
    qux();

v0.4.41

20 Oct 11:34
v0.4.41
b5f7b82
Compare
Choose a tag to compare

Added

  • Add experimental drupal preset (available via --preset drupal)

Changed

  • Review files excluded by default when running from the command line
    • The default regex is now case sensitive: /\/(\.git|\.hg|\.svn|_?build|dist|vendor)\/$/
    • Files in **/tests*/ and **/var/ are no longer excluded by default

Fixed

  • Fix issue where indentation is incorrect when arguments to new static(... break over multiple lines

  • Fix same issue with isset() lists

    Before:

    <?php
    isset($a,
    $b);

    After:

    <?php
    isset($a,
        $b);