cvs: peardoc /en/package/php php-codesniffer.xml /en/package/php/php-codesniffer coding-standard-class.xml coding-standard-tutorial.xml

From: Date: Wed, 04 Apr 2007 00:57:37 +0000
Subject: cvs: peardoc /en/package/php php-codesniffer.xml /en/package/php/php-codesniffer coding-standard-class.xml coding-standard-tutorial.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9595@lists.php.net to get a copy of this message
squiz Wed Apr 4 00:57:37 2007 UTC Added files: /peardoc/en/package/php/php-codesniffer coding-standard-class.xml Modified files: /peardoc/en/package/php php-codesniffer.xml /peardoc/en/package/php/php-codesniffer coding-standard-tutorial.xml Log: Updated PHP_CodeSniffer docs to include information about the new coding standard class requried by all coding standards.

http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-codesniffer.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/php/php-codesniffer.xml diff -u peardoc/en/package/php/php-codesniffer.xml:1.2 peardoc/en/package/php/php-codesniffer.xml:1.3 --- peardoc/en/package/php/php-codesniffer.xml:1.2 Wed Jan 31 21:05:03 2007 +++ peardoc/en/package/php/php-codesniffer.xml Wed Apr 4 00:57:37 2007 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <sect1 id="package.php.php-codesniffer"> <title>PHP_CodeSniffer</title> <para> @@ -18,6 +18,7 @@ &package.php.php-codesniffer.usage; &package.php.php-codesniffer.advanced-usage; &package.php.php-codesniffer.coding-standard-tutorial; + &package.php.php-codesniffer.coding-standard-class; &package.php.php-codesniffer.faq; </sect1> http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml?r1=1.2&r2=1.3&diff_format=u Index: peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml diff -u peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml:1.2 peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml:1.3 --- peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml:1.2 Tue Jan 16 05:03:27 2007 +++ peardoc/en/package/php/php-codesniffer/coding-standard-tutorial.xml Wed Apr 4 00:57:37 2007 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.php.php-codesniffer.coding-standard-tutorial"> <refnamediv> <refname>Coding Standard Tutorial</refname> @@ -16,7 +16,7 @@ <refsect1> <title>Creating the Coding Standard Directory</title> <para> - All sniffs in PHP_CodeSniffer must belong to a coding standard. A coding standard is just a directory inside PHP_CodeSniffer, so we can create one very easily. Let's call our coding standard <emphasis>MyStandard</emphasis>. Run the following commands to create the coding standard directory structure: + All sniffs in PHP_CodeSniffer must belong to a coding standard. A coding standard is a directory inside PHP_CodeSniffer and a single class, so we can create one very easily. Let's call our coding standard <emphasis>MyStandard</emphasis>. Run the following commands to create the coding standard directory structure: </para> <para> <screen> @@ -25,14 +25,70 @@ $ cd /path/to/PHP_CodeSniffer/CodeSniffer/Standards $ mkdir MyStandard $ mkdir MyStandard/Sniffs -$ mkdir MyStandard/Tests ]]> </userinput> </screen> </para> <para> - The <filename>MyStandard</filename> directory represents our coding standard and is the name we will use on the command line to specify the new coding standard to use for checking. The <filename>Sniffs</filename> sub-directory is used to store all the sniff files for this coding standard. The <filename>Tests</filename> sub-directory is used to store unit tests for the sniffs. + The <filename>MyStandard</filename> directory represents our coding standard and is the name we will use on the command line to specify the new coding standard to use for checking. The <filename>Sniffs</filename> sub-directory is used to store all the sniff files for this coding standard. </para> + <para> + Now that our directory structure is created, we need to add our class file. This file will allow PHP_CodeSniffer to ask our coding standard for information about itself, and also identify this directory as one that contains code sniffs. + </para> + <para> + <screen> + <userinput> +<![CDATA[ +$ touch MyStandardCodingStandard.php +]]> + </userinput> + </screen> + </para> + <para> + The content of the <filename>MyStandardCodingStandard.php</filename> file should be the following: + </para> + <para> + <programlisting role="php"> +<![CDATA[ +<?php +/** + * MyStandard Coding Standard. + * + * PHP version 5 + * + * @category PHP + * @package PHP_CodeSniffer + * @author Your Name <you@domain.net> + * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence + * @version CVS: $Id: coding-standard-tutorial.xml,v 1.3 2007/04/04 00:57:37 squiz Exp $ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ + +require_once 'PHP/CodeSniffer/Standards/CodingStandard.php'; + + /** + * MyStandard Coding Standard. + * + * @category PHP + * @package PHP_CodeSniffer + * @author Your Name <you@domain.net> + * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence + * @version Release: @package_version@ + * @link http://pear.php.net/package/PHP_CodeSniffer + */ +class PHP_CodeSniffer_Standards_MyStandard_MyStandardCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard +{ + +}//end class +?> +]]> + </programlisting> + </para> + <note> + <simpara> + The coding standard class can be left empty, as it is in this example coding standard. For information about the methods that can be overridden, see the <link linkend="package.php.php-codesniffer.coding-standard-class">coding standard class documentation</link>. + </simpara> + </note> </refsect1> <refsect1> @@ -109,7 +165,7 @@ * @package PHP_CodeSniffer * @author Your Name <you@domain.net> * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence - * @version CVS: $Id: coding-standard-tutorial.xml,v 1.2 2007/01/16 05:03:27 squiz Exp $ + * @version CVS: $Id: coding-standard-tutorial.xml,v 1.3 2007/04/04 00:57:37 squiz Exp $ * @link http://pear.php.net/package/PHP_CodeSniffer */ http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-codesniffer/coding-standard-class.xml?view=markup&rev=1.1 Index: peardoc/en/package/php/php-codesniffer/coding-standard-class.xml +++ peardoc/en/package/php/php-codesniffer/coding-standard-class.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.php.php-codesniffer.coding-standard-class"> <refnamediv> <refname>Coding Standard Class Methods</refname> <refpurpose>Information about overriding coding standard class methods</refpurpose> </refnamediv> <refsect1> <title>Introduction</title> <para> Every coding standard contains a class file. This file allows PHP_CodeSniffer to ask a coding standard for information about itself, and also identify a directory as one that contains code sniffs. This guide describes each of the coding standard class methods that can be overridden to provide additional information about your coding standard to PHP_CodeSniffer. </para> </refsect1> <refsect1> <title>The getIncludedSniffs() Method</title> <para> This method allows you to tell PHP_CodeSniffer that, besides the code sniffs you have defined in your <filename>Sniffs</filename> directory, you want to include code sniffs from other coding standards. You can include single code sniffs, whole directories of code sniffs, or even an entire coding standard. </para> <para> The example below includes the <literal>MultipleStatementAlignment</literal> sniff from the <literal>Generic</literal> coding standard, all code sniffs in the <literal>Functions</literal> category of the <literal>Generic</literal> coding standard, and all code sniffs defined in the <literal>PEAR</literal> coding standard. </para> <para> <programlisting role="php"> <![CDATA[ <?php /** * Return a list of external sniffs to include with this standard. * * The MyStandard coding standard uses some generic sniffs, and * the entire PEAR coding standard. * * @return array */ function getIncludedSniffs() { return array( 'PEAR', 'Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff', 'Generic/Sniffs/Functions', ); }//end getIncludedSniffs() ?> ]]> </programlisting> </para> <note> <simpara> When including an entire coding standard, you will also include any code sniffs that the standard includes from other coding standards. For example, the <literal>PEAR</literal> coding standard includes some code sniffs from the <literal>Generic</literal> coding standard, so including the entire <literal>PEAR</literal> coding standard will also include those code sniffs. This is a quick and easy way to create your own coding standard based on an existing one. </simpara> </note> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#9595) next »