How do I use php_beautifier with PEAR Code Standards?
Asked
Active
Viewed 1,824 times
1 Answers
2
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.

Gordon
- 312,688
- 75
- 539
- 559
-
and what about variable names? Thank you. – thom Feb 05 '11 at 12:08
-
@thom the PEAR filter is a decorated Default filter. With the exception of the changes listed above, any beautifications of the default filter should apply. If neither PEAR nor Default filter beautify variables according to PEAR standard, you have to add that yourself somehow. – Gordon Feb 05 '11 at 12:18
-
I have the same doubt: "What about local variables inside functions and methods: $my_local_var or $myLocalVar?" found here: http://pear.php.net/manual/pt_BR/standards.naming.php – thom Feb 05 '11 at 12:24
-
1@thom Like I said, if PHP_Beautifier does not do this out of the box, then you have to add it yourself somehow. Consider contributing any improvements you do back to the PEAR project. – Gordon Feb 05 '11 at 12:29