Php code beautification tool-phpCodeBeautifier [integrated in EditPlus]

Source: Internet
Author: User
Tags coding standards

Use PHPCB to add PHP code beautification tool for EditPlus

PHP code formatting tool that can be integrated in EditPlus or other editors: phpCodeBeautifier, phpCB for short.
It beautifies the PHP code format and makes the messy PHP code neat.

 
After EditPlusr is installed, you can choose tools> Configure user tools from the menu bar, choose user tools> Add tools> applications ].
Menu text writing: PHP code beautification; command: select the local storage address of phpCB.
Parameter write: $ (FilePath) or the following content (the command is a line). For details, see phpCodeBeautifier User Manual.
-- Space-after-if -- optimize-eol -- space-after-switch -- space-after-while -- space-before-start-angle-bracket -- space-after-end-angle -bracket -- extra-padding-for-case-statement -- glue-amperscore -- change-shell-comment-to-double-slashes-comment -- indent-with-tab -- force-large -php-code-tag -- force-true-false-null-contant-lowercase -- comment-rendering-style PEAR -- equal-align-position 50 -- padding-char-count 1" $ (FilePath)"

Initial Directory: $ (FileDir)
Finally, select "Run text filtering". In the drop-down box, select "replace,

 

In this way, our PHP code beautification tool has been added,
When you need to use it, you only need to select the PHP code beautification tool in the menu bar,
The program will automatically organize our messy code to make our code more beautiful and easy to read and analyze.

Http://www.waterproof.fr/products/phpCodeBeautifier/manual.php
PhpCodeBeautifier User Manual
Options
-- Space-after-start-bracket: Allow to insert a space after start bracket "(".

With -- space-after-start-bracket Without -- space-after-start-bracket
<? Php

If ($ condition ){
}

?>
<? Php

If ($ condition ){
}

?>
-- Space-before-end-bracket: Allow to insert a space before end bracket ")".

With -- space-before-end-bracket Without -- space-before-end-bracket
<? Php

If ($ condition ){
}

?>
<? Php

If ($ condition ){
}

?>
-- Space-after-if: Allow to insert a space after "if" keyword.

With -- space-after-if Without -- space-after-if
<? Php

If ($ condition ){
}

?>
<? Php

If ($ condition ){
}

?>
-- Space-after-switch: Allow to insert a space after "switch" keyword.

With -- space-after-switch Without -- space-after-switch
<? Php

Switch ($ condition ){
}

?>
<? Php

Switch ($ condition ){
}

?>
-- Space-after-while: Allow to insert a space after "while" keyword.

With -- space-after-while Without -- space-after-while
<? Php

While ($ condition ){
}

?>
<? Php

While ($ condition ){
}

?>
-- Space-before-start-angle-bracket: Allow to insert a space before starting angle bracket "{".

With -- space-before-start-angle-bracket Without -- space-before-start-angle-bracket
<? Php

While ($ condition ){
}

?>
<? Php

While ($ condition ){
}

?>
-- Space-after-end-angle-bracket: Allow to insert a space after starting angle bracket "}".

With -- space-after-end-angle-bracket Without -- space-after-end-angle-bracket
<? Php

While ($ condition ){
} // End of while

?>
<? Php

While ($ condition ){
} // End of while

?>
-- Extra-padding-for-case-statement: Increase padding before case statements.

With -- extra-padding-for-case-statement Without -- extra-padding-for-case-statement
<? Php

Switch ($ condition ){
Case 1:
Action1 ();
Break;
Case 2:
Action2 ();
Break;
Default:
Defaultaction ();
Break;
}

?>
<? Php

Switch ($ condition ){
Case 1:
Action1 ();
Break;
Case 2:
Action2 ();
Break;
Default:
Defaultaction ();
Break;
}

?>
-- One-true-brace-function-declaration: Use "One true brace" formating for functions.

With -- one-true-brace-function-declaration Without -- one-true-brace-function-declaration
<? Php

Function aFunction ($ param)
{
// Function content
}

?>
<? Php

Function aFunction ($ param ){
// Function content
}

?>

-- Glue-amperscore: Glue "&" to following item.

With -- glue-amperscore Without -- glue-amperscore
<? Php

$ Value = & $ objectInstance;

?>
<? Php

$ Value = & $ objectInstance;

?>
-- Change-shell-comment-to-double-slashes-comment: Change "#..." comment into "//..." comments.

Source With -- change-shell-comment-to-double-slashes-comment Without -- change-shell-comment-to-double-slashes-comment
<? Php

# Comment content
// Another comment

?>
<? Php

// Comment content
// Another comment

?>
<? Php

# Comment content
// Another comment

?>
-- Indent-with-tab: If selected, tabulation (ASCII #9) character is used to indent text, elsewhere space (ASCII #32) character is used.

-- Force-large-php-code-tag: Change "<? "And" <% "tokens into" <? Php "and" %> "into"?> ".

Source With -- force-large-php-code-tag Without -- force-large-php-code-tag
<?

?>

<%

%>
<? Php

?>

<? Php

?>
<?

?>

<%

%>
-- Force-true-false-null-contant-lowercase: Lowercase for NULL, TRUE and FALSE constants as encouraged in PEAR coding standards.

Source With -- force-true-false-null-contant-lowercase Without -- force-true-false-null-contant-lowercase
<? Php

If (TRUE ){
If (FALSE ){
$ Value = NULL;
}
}

?>
<? Php

If (true ){
If (false ){
$ Value = null;
}
}

?>
<? Php

If (TRUE ){
If (FALSE ){
$ Value = NULL;
}
}

?>
-- Align-equal-statements: Align all assignement statements.

Source With -- align-equal-statements
<? Php

$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;

$ AnotherVariable [0123] = \ 'bla bla \';

$ ShowBlaBlaBlaMessage = false;

?>
<? Php
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;

?>

 

-- Align-equal-statements-to-fixed-pos: Align all assignement statements to a fixed position.

Source With -- align-equal-statements-to-fixed-pos 30
<? Php

$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;

$ AnotherVariable [0123] = \ 'bla bla \';

$ ShowBlaBlaBlaMessage = false;

?>
<? Php
$ NoError = true;
$ FeildEmpty = false;
$ ShowMessage = false;
$ ShowMessage = false;
$ AnotherVariable [0123] = \ 'bla bla \';
$ ShowBlaBlaBlaMessage = false;

?>

 

Comment rendering style
The following style of comment formating are available:

-- Comment-rendering-style PEAR -- comment-rendering-style PHPDoc
<? Php

/**
* Bla
*
* @ Access public
*/

?>
<? Php

/**
* Bla
*
* @ Access public
*/

?>
PEAR Coding standards Tips
To follow PEAR coding standards, I recommend you to use the following configuration:

Option State
-- Space-after-start-bracket-
-- Space-before-end-bracket-
-- Space-after-if X
-- Space-after-switch X
-- Space-after-while X
-- Space-before-start-angle-bracket X
-- Space-after-end-angle-bracket X
-- Extra-padding-for-case-statement-
-- One-true-brace-function-declaration X
-- Glue-amperscore X
-- Change-shell-comment-to-double-slashes-comment X
-- Indent-with-tab-
-- Force-large-php-code-tag X
-- Force-true-false-null-contant-lowercase X
-- Align-equal-statements X
-- Align-equal-statements-to-fixed-pos-
Use 4 for the padding character count to use.

Command Line
Command line syntax is the following:

PhpCB.exe [options] [srcFile]
Where options is from the previous topic list and srcFile is the file to beautify. if no srcFile is given, standard input will be used. the transformed text will be outputted to standard output, you can redirect it to a file using the> symbol.
Example
This is a sample call of the command line version:

# PhpCB -- space-after-if \
-- Space-after-switch \
-- Space-after-while \
-- Space-before-start-angle-bracket \
-- Space-after-end-angle-bracket \
-- One-true-brace-function-declaration \
-- Glue-amperscore \
-- Change-shell-comment-to-double-slashes-comment \
-- Force-large-php-code-tag \
-- Force-true-false-null-contant-lowercase \
-- Align-equal-statements \
-- Comment-rendering-style PEAR \
-- Equal-align-position 50 \
-- Padding-char-count 4 \
C: \ some \ path \ to \ file. php
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.