View file index.html

File size: 24.25Kb
<html>
<head>
    <title>phpCodeBeautifier Documentation</title>
</head>
<style>

body, table{
    font-family: Verdana;
    font-size: 11px;
}

/* h1 only used in header */
h1, h2,h3,h4,h5,h6 {
    padding:        2px 10px 2px 10px;
    background:        rgb(234,242,255);
    border:            1px solid rgb(120,172,255);
}

h1,h2 {
    font-weight:    normal;
}

h3,h4,h5,h6 {
    font-weight:    bold;
}

h1 {
    font-size:        30px;
}

h2 {
    font-size:        20px;
    margin-right:    10px;
}

h3 {
    font-size:        13px;
    margin-right:    10px;
}

a {
    text-decoration: none;
    border-bottom: 1px dotted #FF9900;
    padding-left: 2px;
    padding-right: 2px;
}

a {
    color:            rgb(0,66,174);
}

a:hover {/*rgb(0,66,174)*/
    color:            rgb(120,172,255);
}

a:visited {
    color:            rgb(0,66,174);
}

a:visited:hover {
    color:            rgb(120,172,255);
}

span.shortcut{
    background-color:        #EEEEEE;
    border:            1px solid #BBBBBB;
    padding:        2px 2px 0px 0px;
}

span.commandProto {
    border: 1px solid #BBBBBB;
    background : #F0F0F0;
    padding : 2px 2px 2px 2px;
    margin : 2px 2px 2px 2px;
}

span.commandProtoParameter{
    font-weight : bold;
}

img {
    margin: 1px 1px 1px 1px;
}

img.alLeft {
    float: left;
}


img.alCenter {
    float: none;
}


img.alRight {
    float: right;
}

pre.example, pre.ChangeLog {
    padding-right:    2px;
    padding-left:    2px;
    background-color:        #F9F9F9;
    border:            1px solid #BBBBBB;

}

span.redMark {
    background-color:        #FFBBBB;
    border:            1px solid #FF9999;
}

thead td {
    padding-right:    2px;
    padding-left:    2px;
    background-color:        #EEEEEE;
    border:            1px solid #BBBBBB;
}
</style>
<body>
<h1>phpCB: PHP Code Beautifier</h1>
<h2>Summary</h2>
<ul>
	<li><a href="#Introduction">Introduction</a></li>
	<li><a href="#ChangeLog">ChangeLog</a></li>
	<li><a href="#Download">Download</a></li>
	<li><a href="#Options">Options</a></li>
	<li><a href="#CommentRenderingStyle">Comment rendering style</a></li>
	<li><a href="#PEARStandards">PEAR Coding standards Tips</a></li>
	<li><a href="#Example">Example</a></li>
</ul>

<a name="Introduction"></a>
<h2>Introduction</h2>
<p>phpCodeBeautifier has been written by <a href="mailto:[email protected]">Sйbastien Hordeaux</a> and is copyright 2002 of myself. Contact me before including it in any package (commercial or not).</p>
<p>The main goal of this tool is to avoid spending hours on reformating code to suit my own way of presenting it. The tool has been declined into 3 versions:
<ol>
	<li>A GUI version which allow to process file visually.</li>
	<li>A command line version which allow to be batched or integrated with other tools (CVS, IDE, ...)</li>
	<li>As an integrated tool of <a href="http://www.phpedit.net/">PHPEdit</a>.</li>
</ol></p>
<p>I hope this tool will assist you as it does for me. If you find bug, please feel free to report them in the <a href="http://community.phpedit.net/">bug tracker</a>.</p>

<p>This tool has required work; you are encouraged to reward this work by making a donation, this is the only way to encourage us to continue developping tools like this one and keeping them free.
	<center>
	<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
		<input type="hidden" name="cmd" value="_xclick">
		<input type="hidden" name="business" value="[email protected]">
		<input type="hidden" name="item_name" value="PHPEdit Donation">
		<input type="hidden" name="item_number" value="PHPEDIT-DONATION-01">
		<input type="hidden" name="image_url" value="http://www.phpedit.net/images/logo_150x50.gif">
		<input type="hidden" name="no_shipping" value="1">
		<input type="image" src="x-click-butcc-donate.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
	</form>
	</center>
</p>

<p>Check <a href="http://www.phpedit.net/products/phpCodeBeautifier/">http://www.phpedit.net/products/phpCodeBeautifier/</a> for last updates.</p>

<a name="ChangeLog"></a>
<h2>ChangeLog</h2>

<pre class="ChangeLog">

2003-09-18 - Version 0.8

  ~ This version owns all fixes done inside PHPEdit.

2003-01-07 - Version 0.7.7

  + #1062 Added cboRewriteOnlyDocumentationComment option in the code beautifier.
  + Added cboOneTrueBrace in the code beautifier
  - Fixed bug #1054: If /Else indentation
  - Fixed bug #1054: do {} while is not correct indented
  - Fixed bug #971: PHP Interpreter line command modified

2002-12-26 - Version 0.7.6

  - Fixed bug #1146:  Tick `` code is removed.
    http://bugs.phpedit.net/view_bug_advanced_page.php?f_id=0001146

2002-12-02 - Version 0.7.5

  - Fixed bug #1105: Command line exe (phpcb.exe) does not support
    --optimize-eol - http://bugs.phpedit.net/view_bug_advanced_page.php?f_id=0001105

2002-11-03 - Version 0.7.4

  - Fixed problem with if inside switchs

2002-10-01 - Version 0.7.3

  + Added --glue-arrow option to strip spaces bfore and after -> (or to add one if option is not available)
  + Added --remove-comments option to remove all comments from the processed file.
  + Added --optimize-eol which strip all useless lines (>1 consecutive line end is changed into a single EOL)

2002-09-14 - Version 0.7.2

  + Added support for multiple configuration files.
  - Fixed bug #744: http://bugs.phpedit.net/view_bug_page.php?f_id=0000744
  - Fixed bug #741: http://bugs.phpedit.net/view_bug_page.php?f_id=0000741
  - Fixed bug #740: http://bugs.phpedit.net/view_bug_page.php?f_id=0000740
  - Fixed bug #742: http://bugs.phpedit.net/view_bug_page.php?f_id=0000742
  - Fixed bug #626: http://bugs.phpedit.net/view_bug_page.php?f_id=0000626

2002-09-13

  + Added file format support.
  ~ The progress bar is now hidden when the code beautifier is inactive.

2002-08-04 - Version 0.7.1

  + Added the ability to drop files to open them.
  + Added scrolling synchronization between both Before & After form.

Missing ChangeLog items before that...

</pre>

<a name="Download"></a>
<h2>Download</h2>

<p>Current version is <b>0.8</b>. You can download it <a href="http://www.phpedit.net/products/phpCodeBeautifier/download.php">here</a>.</p>

<a name="Options"></a>
<h2>Options</h2>
<ul>
    <li>
        <p><b>--space-after-start-bracket</b>: Allow to insert a space after start bracket '('.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-after-start-bracket</td>
                    <td width="50%">Without --space-after-start-bracket</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

if (<span class="redMark"> </span>$condition) {
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

if ($condition) {
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-before-end-bracket</b>: Allow to insert a space before end bracket ')'.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-before-end-bracket</td>
                    <td width="50%">Without --space-before-end-bracket</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

if ($condition<span class="redMark"> </span>) {
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

if ($condition) {
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-after-if</b>: Allow to insert a space after 'if' keyword.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-after-if</td>
                    <td width="50%">Without --space-after-if</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

if<span class="redMark"> </span>($condition) {
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

if($condition) {
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-after-switch</b>: Allow to insert a space after 'switch' keyword.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-after-switch</td>
                    <td width="50%">Without --space-after-switch</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

switch<span class="redMark"> </span>($condition) {
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

switch($condition) {
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-after-while</b>: Allow to insert a space after 'while' keyword.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-after-while</td>
                    <td width="50%">Without --space-after-while</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

while<span class="redMark"> </span>($condition) {
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

while($condition) {
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-before-start-angle-bracket</b>: Allow to insert a space before starting angle bracket '{'.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-before-start-angle-bracket</td>
                    <td width="50%">Without --space-before-start-angle-bracket</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

while($condition)<span class="redMark"> </span>{
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

while($condition){
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--space-after-end-angle-bracket</b>: Allow to insert a space after starting angle bracket '}'.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --space-after-end-angle-bracket</td>
                    <td width="50%">Without --space-after-end-angle-bracket</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

while($condition){
}<span class="redMark"> </span>// end of while

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

while($condition){
}// end of while

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--extra-padding-for-case-statement</b>: Increase padding before case statements.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --extra-padding-for-case-statement</td>
                    <td width="50%">Without --extra-padding-for-case-statement</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

switch($condition){
<span class="redMark">    </span>case 1:
<span class="redMark">    </span>    action1();
<span class="redMark">    </span>    break;
<span class="redMark">    </span>case 2:
<span class="redMark">    </span>    action2();
<span class="redMark">    </span>    break;
<span class="redMark">    </span>default:
<span class="redMark">    </span>    defaultaction();
<span class="redMark">    </span>    break;
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

switch($condition){
case 1:
    action1();
    break;
case 2:
    action2();
    break;
default:
    defaultaction();
    break;
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--one-true-brace-function-declaration</b>: Use "One true brace" formating for functions.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --one-true-brace-function-declaration</td>
                    <td width="50%">Without --one-true-brace-function-declaration</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

function aFunction($param)<span class="redMark">
</span>{
    // function content
}

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

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

?&gt;

</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--glue-amperscore</b>: Glue "&amp;" to following item.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">With --glue-amperscore</td>
                    <td width="50%">Without --glue-amperscore</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

$value = &amp;$objectInstance;

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

$value = &amp;<span class="redMark"> </span>$objectInstance;

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--change-shell-comment-to-double-slashes-comment</b>: Change "# ..." comment into "// ..." comments.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="33%">Source</td>
                    <td width="33%">With --change-shell-comment-to-double-slashes-comment</td>
                    <td width="33%">Without --change-shell-comment-to-double-slashes-comment</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="33%"><pre class="example">
&lt;?php

#comment content
//another comment

?&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;?php

<span class="redMark">// </span>comment content
//<span class="redMark"> </span>another comment

?&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;?php

#<span class="redMark"> </span>comment content
//<span class="redMark"> </span>another comment

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--indent-with-tab</b>: If selected, tabulation (ASCII #9) character is used to indent text, elsewhere space (ASCII #32) character is used.</p>
    </li>
    <li>
        <p><b>--force-large-php-code-tag</b>: Change "&lt;?" and "&lt;%" tokens into "&lt;?php" and "%&gt;" into "?&gt;".</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="33%">Source</td>
                    <td width="33%">With --force-large-php-code-tag</td>
                    <td width="33%">Without --force-large-php-code-tag</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="33%"><pre class="example">
&lt;?

?&gt;

&lt;%

%&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;<span class="redMark">?php</span>

?&gt;

&lt;<span class="redMark">?php</span>

<span class="redMark">?</span>&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;?

?&gt;

&lt;%

%&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--force-true-false-null-contant-lowercase</b>: Lowercase for NULL, TRUE and FALSE constants as encouraged in PEAR coding standards.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="33%">Source</td>
                    <td width="33%">With --force-true-false-null-contant-lowercase</td>
                    <td width="33%">Without --force-true-false-null-contant-lowercase</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="33%"><pre class="example">
&lt;?php

if(TRUE){
    if(FALSE){
        $value = NULL;
    }
}

?&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;?php

if(<span class="redMark">true</span>){
    if(<span class="redMark">false</span>){
        $value = <span class="redMark">null</span>;
    }
}

?&gt;</pre></td>
                    <td width="33%"><pre class="example">
&lt;?php

if(TRUE){
    if(FALSE){
        $value = NULL;
    }
}

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--align-equal-statements</b>: Align all assignement statements.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">Source</td>
                    <td width="50%">With --align-equal-statements</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;

$anotherVariable[0123] = 'bla bla bla';

$showBlaBlaBlaMessage = false;

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php
$noError<span class="redMark">              </span> = true;
$feildEmpty<span class="redMark">           </span> = false;
$showMessage<span class="redMark">          </span> = false;
$showMessage<span class="redMark">          </span> = false;
$anotherVariable[0123] = 'bla bla bla';
$showBlaBlaBlaMessage<span class="redMark"> </span> = false;

?&gt;



</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>
    <li>
        <p><b>--align-equal-statements-to-fixed-pos</b>: Align all assignement statements to a fixed position.</p>

        <p>
            <table width="80%">
                <thead>
                <tr>
                    <td width="50%">Source</td>
                    <td width="50%">With --align-equal-statements-to-fixed-pos 40</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

$noError = true;
$feildEmpty = false;
$showMessage = false;
$showMessage = false;

$anotherVariable[0123] = 'bla bla bla';

$showBlaBlaBlaMessage = false;

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php
$noError<span class="redMark">                              </span> = true;
$feildEmpty<span class="redMark">                           </span> = false;
$showMessage<span class="redMark">                          </span> = false;
$showMessage<span class="redMark">                          </span> = false;
$anotherVariable[0123]<span class="redMark">                </span> = 'bla bla bla';
$showBlaBlaBlaMessage<span class="redMark">                 </span> = false;

?&gt;



</pre></td>
                </tr>
                </tbody>
            </table>
        </p>
    </li>

</ul>


<a name="CommentRenderingStyle"></a>
<h2>Comment rendering style</h2>

<p>The following style of comment formating are available:</p>
        <p>
            <table width="100%">
                <thead>
                <tr>
                    <td width="50%"><b>--comment-rendering-style</b> PEAR</td>
                    <td width="50%"><b>--comment-rendering-style</b> PHPDoc</td>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td width="50%"><pre class="example">
&lt;?php

/**
 * bla bla bla
 *
 * @access public
 */

?&gt;</pre></td>
                    <td width="50%"><pre class="example">
&lt;?php

/**
* bla bla bla
*
* @access public
*/

?&gt;</pre></td>
                </tr>
                </tbody>
            </table>
        </p>


<a name="PEARStandards"></a>
<h2>PEAR Coding standards Tips</h2>
<p>To follow <a href="http://pear.php.net/manual/en/standards.php">PEAR coding standards</a>, I recommend you to use the following configuration:</p>
<p><table width="400">
	<thead>
		<tr>
			<td width="350">Option</td>
			<td width="50" align="center">State</td>
		</tr>
	</thead>
	<tbody>
		<tr><td>--space-after-start-bracket</td><td align="center">-</td></tr>
		<tr><td>--space-before-end-bracket</td><td align="center">-</td></tr>
		<tr><td>--space-after-if</td><td align="center">X</td></tr>
		<tr><td>--space-after-switch</td><td align="center">X</td></tr>
		<tr><td>--space-after-while</td><td align="center">X</td></tr>
		<tr><td>--space-before-start-angle-bracket</td><td align="center">X</td></tr>
		<tr><td>--space-after-end-angle-bracket</td><td align="center">X</td></tr>
		<tr><td>--extra-padding-for-case-statement</td><td align="center">-</td></tr>
		<tr><td>--one-true-brace-function-declaration</td><td align="center">X</td></tr>
		<tr><td>--glue-amperscore</td><td align="center">X</td></tr>
		<tr><td>--change-shell-comment-to-double-slashes-comment</td><td align="center">X</td></tr>
		<tr><td>--indent-with-tab</td><td align="center">-</td></tr>
		<tr><td>--force-large-php-code-tag</td><td align="center">X</td></tr>
		<tr><td>--force-true-false-null-contant-lowercase</td><td align="center">X</td></tr>
		<tr><td>--align-equal-statements</td><td align="center">X</td></tr>
		<tr><td>--align-equal-statements-to-fixed-pos</td><td align="center">-</td></tr>
	</tbody>
</table>
</p>
<p>Use 4 for the padding character count to use.</p>


<a name="Example"></a>
<h2>Example</h2>
<p>This is a sample call of the command line version:</p>
<pre class="example">
# 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

</pre>

</body>
</html>