Changeset 328

Show
Ignore:
Timestamp:
12/22/07 13:55:23 (7 months ago)
Author:
dthomas
Message:

Refs #202 - Added PHP_CodeSniffer task and documentation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.3/classes/phing/tasks/defaults.properties

    r317 r328  
    8282jsllint=phing.tasks.ext.JslLintTask 
    8383manifest=phing.tasks.ext.ManifestTask 
     84phpcodesniffer=phing.tasks.ext.PhpCodeSnifferTask 
  • branches/2.3/docs/phing_guide/book/chapters/appendixes/AppendixC-OptionalTasks.html

    r318 r328  
    856856  <li>mapping</li> 
    857857</ul> 
     858 
     859<h2><a name="PhpCodeSnifferTask"></a>PhpCodeSnifferTask</h2> 
     860<p>This task runs <a href="http://pear.php.net/package/PHP_CodeSniffer" target="_blank">PHP_CodeSniffer</a> to detect violations of a defined set of coding standards.</p> 
     861<h3>Attributes</h3> 
     862<table> 
     863  <thead> 
     864    <tr> 
     865      <th>Name</th> 
     866      <th>Type</th> 
     867      <th>Description</th> 
     868      <th>Default</th> 
     869      <th>Required</th> 
     870    </tr> 
     871  </thead> 
     872  <tbody> 
     873    <tr> 
     874      <td>standard</td> 
     875      <td>String</td> 
     876      <td>The name of the standard or an absolute path to an external standard to check for.</td> 
     877      <td>Generic</td> 
     878      <td>No</td> 
     879    </tr> 
     880    <tr> 
     881      <td>outputFormat</td> 
     882      <td>String</td> 
     883      <td>The output format. The <em>default</em> format is specified in the task itself. Additionally the formats of CodeSniffer can be choosen: <em>xml</em>, <em>checkstyle</em>, <em>csv</em>, <em>report</em> and <em>summary</em>. A special case is the format <em>doc</em> which generates the documentation of the standard.</td> 
     884      <td>default</td> 
     885      <td>No</td> 
     886    </tr> 
     887    <tr> 
     888      <td>showSniffs</td> 
     889      <td>Boolean</td> 
     890      <td>Print the list of used sniffs.</td> 
     891      <td>false</td> 
     892      <td>No</td> 
     893    </tr> 
     894    <tr> 
     895      <td>showWarnings</td> 
     896      <td>Boolean</td> 
     897      <td>Print warnings.</td> 
     898      <td>true</td> 
     899      <td>No</td> 
     900    </tr> 
     901    <tr> 
     902      <td>file</td> 
     903      <td>String</td> 
     904      <td>The file or folder to check (usally the nested tag <em>fileset</em> is used instead).</td> 
     905      <td>false</td> 
     906      <td>Either this attribute or the nested tag <em>fileset</em> is required.</td> 
     907    </tr> 
     908    <tr> 
     909      <td>sniffs</td> 
     910      <td>String</td> 
     911      <td>The list of allowed sniffs (separated by space, comma or semicolon). The sniffs must be part of the choosen standard.</td> 
     912      <td>n/a</td> 
     913      <td>No</td> 
     914    </tr> 
     915    <tr> 
     916      <td>verbosity</td> 
     917      <td>Integer</td> 
     918      <td>The verbosity level of CodeSniffer where level 1 prints progress information and level 2 prints developer debug information.</td> 
     919      <td>0</td> 
     920      <td>No</td> 
     921    </tr> 
     922    <tr> 
     923      <td>tabWidth</td> 
     924      <td>Integer</td> 
     925      <td>Replaces tabs with the given number of spaces. If zero no replacing is done.</td> 
     926      <td>0</td> 
     927      <td>No</td> 
     928    </tr> 
     929    <tr> 
     930      <td>allowedFileExtensions</td> 
     931      <td>String</td> 
     932      <td>The allowed file extensions (separated by space, comma or semicolon) when a directory is specified in the <em>file</em> attribute.</td> 
     933      <td>php</td> 
     934      <td>No</td> 
     935    </tr> 
     936    <tr> 
     937      <td>ignorePatterns</td> 
     938      <td>String</td> 
     939      <td>The patterns to ignore files and folders (separated by space, comma or semicolon) when a directory is specified in the <em>file</em> attribute.</td> 
     940      <td>n/a</td> 
     941      <td>No</td> 
     942    </tr> 
     943    <tr> 
     944      <td>noSubdirectories</td> 
     945      <td>Boolean</td> 
     946      <td>Do not recurse into subdirectories when a directory is specified in the <em>file</em> attribute.</td> 
     947      <td>false</td> 
     948      <td>No</td> 
     949    </tr> 
     950  </tbody> 
     951</table> 
     952<h3>Supported Nested Tags</h3> 
     953<ul> 
     954  <li>fileset 
     955    <p>Either this nested tag or the attribute <em>file</em> is required.</p> 
     956  </li> 
     957  <li>config 
     958    <p>The configuration parameters which are usally loaded from the CodeSniffer.conf can be set.</p> 
     959    <h3>Attributes</h3> 
     960    <table> 
     961      <thead> 
     962        <tr> 
     963          <th>Name</th> 
     964          <th>Type</th> 
     965          <th>Description</th> 
     966          <th>Default</th> 
     967          <th>Required</th> 
     968        </tr> 
     969      </thead> 
     970      <tbody> 
     971        <tr> 
     972          <td>name</td> 
     973          <td>String</td> 
     974          <td>Name of the configuration parameter. </td> 
     975          <td>n/a</td> 
     976          <td>Yes</td> 
     977        </tr> 
     978        <tr> 
     979          <td>value</td> 
     980          <td>String</td> 
     981          <td>Value of the configuration parameter. </td> 
     982          <td>n/a</td> 
     983          <td>Yes</td> 
     984        </tr> 
     985      </tbody> 
     986    </table> 
     987  </li> 
     988</ul> 
     989<h3>Examples</h3> 
     990<p>Checks all files in the directory <em>file</em> matching the allowed file extension with the <em>PEAR</em> standard and prints the <em>summary</em> report without warnings.</p> 
     991<pre>&lt;phpcodesniffer 
     992  standard=&quot;PEAR&quot; 
     993  format=&quot;summary&quot; 
     994  file=&quot;/path/to/source-files&quot; 
     995  allowedFileExtensions=&quot;php php5 inc&quot;/&gt; 
     996&lt;/phpcodesniffer&gt; 
     997</pre> 
     998<p>Checks all matching files in the directory <em>dir</em> with a custom external standard, sets the <em>zend_ca_path</em> configuration which may be required by one of the sniffs, prints a list of used sniffs and prints the <em>default</em> report with warnings.</p> 
     999<pre>&lt;phpunit 
     1000  standard=&quot;/path/to/external-standard&quot; 
     1001  showSniffs=&quot;true&quot; 
     1002  showWarnigns=&quot;true&quot;&gt; 
     1003  &lt;fileset dir=&quot;/path/to/source-files&quot;&gt; 
     1004    &lt;include name=&quot;**/*.php&quot;/&gt; 
     1005  &lt;/fileset&gt; 
     1006  &lt;config name=&quot;zend_ca_path&quot; value=&quot;/path/to/ZendStudio/bin/ZendCodeAnalyzer&quot;&gt; 
     1007&lt;/phpunit&gt; 
     1008</pre> 
     1009<p>Externally stored custom standard have to follow the same naming conventions as if they were stored in the <em>Standards</em> subdirectory of PHP_CodeSniffer itself.</p> 
    8581010 
    8591011<h2><a name="PhpDocumentorTask"></a>PhpDocumentorTask</h2> 
  • branches/2.3/docs/phing_guide/book/toc/FrameToC.html

    r318 r328  
    132132<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PearPackageTask" target="Content">PearPackageTask</a></li> 
    133133<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PearPackage2Task" target="Content">PearPackage2Task</a></li> 
     134<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpCodeSnifferTask" target="Content">PhpCodeSnifferTask</a></li> 
    134135<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpDocumentorTask" target="Content">PhpDocumentorTask</a></li> 
    135136<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpLintTask" target="Content">PhpLintTask</a></li> 
  • branches/2.3/docs/phing_guide/book/toc/ToC.html

    r318 r328  
    117117<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PearPackageTask">PearPackageTask</a></li> 
    118118<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PearPackage2Task">PearPackage2Task</a></li> 
     119<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpCodeSnifferTask">PhpCodeSnifferTask</a></li> 
    119120<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpDocumentorTask">PhpDocumentorTask</a></li> 
    120121<li><a href="../chapters/appendixes/AppendixC-OptionalTasks.html#PhpLintTask">PhpLintTask</a></li>