PHPStyle ✨

Stop living with ugly PHP, but don't waste time ⏰ cleaning it up!

🏗 Setup is easy

Install the PHPStyle package with composer

composer require jspaetzel/phpstyle --dev

Edit the default phpstyle.neon file as needed

parameters:
    php: 7.1
    risky: false
    paths:
        - src
        - tests
    excludePaths:
        - src/path/you/want/to/skip
        - src/or/a/file-to-skip.php

Run the fixer

./vendor/bin/php-cs-fixer fix
That's all, re-run the fixer anytime files change!

What will PHPStyle do to your code? See a preview below

class YourWorstNightmare {
/**   @var string    */
var $private;
public function __construct(){ $array = array(
        'wait'=>'itgetsworse');
    $bool = (BOOLEAN) 1;
    $ternaries=$bool?0 : 1;
    if ($bool) { echo 'hello' ; } else
        if ($ternaries === 1) { echo "goodbye";   }
} function dosomething(): ?string {
    return ""; }

}

$nightmare=new YourWorstNightmare() ;
class YourWorstNightmare
{
    /** @var string */
    public $private;

    public function __construct()
    {
        $array = [
            'wait' => 'itgetsworse',
        ];
        $bool = (bool) 1;
        $ternaries = $bool ? 0 : 1;
        if ($bool) {
            echo 'hello';
        } elseif ($ternaries === 1) {
            echo 'goodbye';
        }
    }

    public function dosomething(): ?string
    {
        return '';
    }
}

$nightmare = new YourWorstNightmare();

Credits

PHPStyle is made possible by the very fine php-cs-fixer project. PHPStyle is a simple wrapper around php-cs-fixer with sane defaults and some configuration options exposed as a yaml configuration file for easier use.