github lkrms/pretty-php v0.4.57

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

Added

  • Detect indentation of input files for more accurate tab expansion

Changed

  • Improve CLI option validation and error messages

  • Treat case statements in enumerations as declarations for more consistent vertical whitespace and DocBlock handling

  • Always collapse one-line DocBlocks before global and static variable declarations

  • Collapse and ignore one-line DocBlocks with a PHPDoc tag when applying vertical whitespace to consecutive one-line declarations

    Before (DocBlock triggers vertical expansion):

    <?php
    class Foo
    {
        public int $Bar;
        public string $Qux;
    
        /**
         * @var string[]
         */
        public array $Quux = [];
    }

    After (DocBlock is collapsed if there are no blank lines between property declarations):

    <?php
    class Foo
    {
        public int $Bar;
        public string $Qux;
        /** @var string[] */
        public array $Quux = [];
    }
  • Improve DocBlock normalisation when leading asterisks are missing

    Input:

    <?php
    
    /**
     * Comment
     *
     @api
     */
    
    /*
     *
    
    List:
    * Item 1
    * Item 2
    
     */

    Previous output:

    <?php
    
    /**
     * * Comment
     * *
     * @api
     */
    
    /*
     * List:
     * Item 1
     * Item 2
     */

    Current output:

    <?php
    
    /**
     * Comment
     *
     * @api
     */
    
    /*
     * List:
     * * Item 1
     * * Item 2
     */

Fixed

  • Fix issue where braces with a nested match expression may be incorrectly parsed as a complete statement

Don't miss a new pretty-php release

NewReleases is sending notifications on new releases.