phpcoding-stylepearcode-formattingphp-beautifier

How do I use php_beautifier with PEAR Code Standards?


How do I use php_beautifier with PEAR Code Standards?


Solution

  • You have to use PHP_Beautifier_Filter_Pear instead of the default filter.

    $oBeaut->addFilter('Pear',array('add_header'=>'php'));
    

    Or from CLI

    $ php_beautifier --filters "Pear(add_header=php)"
    

    The PEAR filter will

    • Add 2 newlines after Break in switch statements. Break indent is the same of previous line
    • Brace in function definition put on a new line, same indent of 'function' construct
    • Comments started with '#' are replaced with '//'
    • Open tags are replaced with <?php
    • T_OPEN_TAG_WITH_ECHO replaced with <?php echo
    • With setting 'add_header', the filter add one of the standard PEAR comment header (php, bsd, apache, lgpl, pear) or any file as licence header.