github lkrms/pretty-php v0.4.44

latest releases: v0.4.72, v0.4.71, v0.4.70...
9 months ago

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

Don't miss a new pretty-php release

NewReleases is sending notifications on new releases.