Re: PHP_Beautifier
| From: | Jeff Kowalczyk | Date: | Tue, 08 Aug 2006 15:02:30 +0000 |
| Subject: | Re: PHP_Beautifier | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24858@lists.php.net to get a copy of this message | ||
On Tue, 25 Jul 2006 12:34:01 -0400, Jeff Kowalczyk wrote:
> I am very glad to find PEAR's PHP_Beautifier(-0.1.11). I hadn't expected
> to find a capable and actively developed tool to perform some much needed
> cleanup on a large PHP codebase.
>
> The auto-generated documentation is not revealing the first question I
> have:
>
> How do I force a newline after every comma separated argument to a
> function, array constructor, etc.
>
> I want to strongly move this codebase toward vertical formatting, with
> liberal use of newline rules to keep line length down.
>
> This original formatting:
>
> var $range_fields = Array(
> 'first_name',
> 'last_name',
> 'primary_address_city',
> 'account_name',
> 'account_id',
> 'id',
> 'email1',
> 'salutation',
> 'title',
> 'phone_mobile',
> 'reports_to_name',
> 'primary_address_street',
> 'primary_address_city',
> 'primary_address_state',
> 'primary_address_postalcode',
> 'primary_address_country',
> 'alt_address_city',
> 'alt_address_street',
> 'alt_address_city',
> 'alt_address_state',
> 'alt_address_postalcode',
> 'alt_address_country',
> 'office_phone',
> 'home_phone',
> 'other_phone',
> 'fax',
> 'department',
> 'birthdate',
> 'assistant_name',
> 'assistant_phone');
>
> Cannot become this:
>
> var $range_fields = Array('first_name', 'last_name',
> 'primary_address_city', 'account_name', 'account_id',
> 'id', 'email1',
> 'salutation', 'title', 'phone_mobile',
> 'reports_to_name',
> 'primary_address_street', 'primary_address_city',
> 'primary_address_state', 'primary_address_postalcode',
> 'primary_address_country', 'alt_address_city',
> 'alt_address_street',
> 'alt_address_city', 'alt_address_state',
> 'alt_address_postalcode',
> 'alt_address_country', 'office_phone', 'home_phone',
> 'other_phone',
> 'fax', 'department', 'birthdate', 'assistant_name',
> 'assistant_phone');
>
> (which, as pasted, doesn't have any newlines)
>
> Is there anywhere I can read/examine all the acceptable options to the
> newlines filter?
>
> php_beautifier -f file.php -o file.php.beautified \
> --filters "NewLines(before=if:switch:T_CLASS,after=T_COMMENT:function)"
>
> Thanks.
I'm coming down to crunch time if I want to get the codebase of the
project in question beautified before major branching occurs.
Can anyone suggest a php_beautifier command line that achieves the
following objectives:
- PEAR code standards as a baseline. There is a filter for this.
- A single blank line before and after any code element with brackets,
e.g. class, function, if, switch, etc. The opening bracket position is per
PEAR standards.
- function arguments indented and one per line, as illustrated above.
Overkill for short arg lists, but invaluable for long arg lists.
- long lines sanely wrapped before col 80, but strings (e.g containing SQL
statements) unmodified. We use ADODB and have a separate requirement to
beautify these strings by hand. This seems to be the php_beautify and PEAR
filter default.
Thanks for any help, I only have a few days remaining to try to get this
proposed, tested, and committed to the project's codebase.