cvs: peardoc /en/package/php php-codesniffer.xml /en/package/php/php-codesniffer svn-pre-commit.xml

From: Date: Mon, 07 Jul 2008 04:57:36 +0000
Subject: cvs: peardoc /en/package/php php-codesniffer.xml /en/package/php/php-codesniffer svn-pre-commit.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10970@lists.php.net to get a copy of this message
squiz Mon Jul 7 04:57:36 2008 UTC Added files: /peardoc/en/package/php/php-codesniffer svn-pre-commit.xml Modified files: /peardoc/en/package/php php-codesniffer.xml Log: Added docs for setting up the svn pre-commit hook http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-codesniffer.xml?r1=1.4&r2=1.5&diff_format=u Index: peardoc/en/package/php/php-codesniffer.xml diff -u peardoc/en/package/php/php-codesniffer.xml:1.4 peardoc/en/package/php/php-codesniffer.xml:1.5 --- peardoc/en/package/php/php-codesniffer.xml:1.4 Wed Sep 19 04:40:32 2007 +++ peardoc/en/package/php/php-codesniffer.xml Mon Jul 7 04:57:35 2008 @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <sect1 id="package.php.php-codesniffer"> <title>PHP_CodeSniffer</title> <para> PHP_CodeSniffer is a PHP5 script that tokenises - and &quot;sniffs&quot; PHP code to detect violations - of a defined set of coding standards. + and &quot;sniffs&quot; PHP and JavaScript code to detect violations + of a defined coding standard. It is an essential development tool that ensures that your code remains clean and consistent. - It can even help prevent some common semantic + It can also help prevent some common semantic errors made by developers. </para> @@ -20,6 +20,7 @@ &package.php.php-codesniffer.config-options; &package.php.php-codesniffer.coding-standard-tutorial; &package.php.php-codesniffer.coding-standard-class; + &package.php.php-codesniffer.svn-pre-commit; &package.php.php-codesniffer.faq; </sect1> http://cvs.php.net/viewvc.cgi/peardoc/en/package/php/php-codesniffer/svn-pre-commit.xml?view=markup&rev=1.1 Index: peardoc/en/package/php/php-codesniffer/svn-pre-commit.xml +++ peardoc/en/package/php/php-codesniffer/svn-pre-commit.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.php.php-codesniffer.svn-pre-commit"> <refnamediv> <refname>Using the Subversion pre-commit Hook</refname> <refpurpose>How to configure the Subversion pre-commit hook</refpurpose> </refnamediv> <refsect1 id="package.php.php-codesniffer.svn-pre-commit.introduction"> <title>What Does the Subversion pre-commit Hook Do?</title> <para> A pre-commit hook is a feature available in the <ulink url="http://subversion.tigris.org">Subversion</ulink> version control system that allows code to be validated before it is committed to the repository. The PHP_CodeSniffer pre-commit hook allows you to check code for coding standard errors and stop the commit process if errors are found. This ensures developers are not able to commit code that violates your coding standard. Instead, they are presented with the list of errors they need to correct before committing. </para> <example> <title>Sample pre-commit output</title> <screen> <![CDATA[ $ svn commit -m "Test" temp.php Sending temp.php Transmitting file data .svn: Commit failed (details follow): svn: 'pre-commit' hook failed with error output: FILE: temp.php --------------------------------------------------------------- FOUND 1 ERROR(S) AND 0 WARNING(S) AFFECTING 1 LINE(S) --------------------------------------------------------------- 2 | ERROR | Missing file doc comment -------------------------------------------------------------- ]]> </screen> </example> </refsect1> <refsect1 id="package.php.php-codesniffer.svn-pre-commit.setup"> <title>Configuring the pre-commit Hook</title> <para> Edit <filename>/path/to/PHP_CodeSniffer/scripts/phpcs-svn-pre-commit</filename> and replace <literal>@php_bin@</literal> in the first line with the path to the PHP CLI. For example, <literal>#!@php_bin@</literal> becomes <literal>#!/usr/bin/php</literal>. </para> <para> Now ensure the path to <literal>svnlook</literal> is correct by modifying the following line, if required: </para> <example> <title>Changing the path to <literal>svnlook</literal></title> <screen> <![CDATA[ define('PHP_CODESNIFFER_SVNLOOK', '/usr/bin/svnlook'); ]]> </screen> </example> <para> Now add the following line to your pre-commit file in the Subversion hooks directory: </para> <example> <title>Adding the pre-commit hook to the Subversion config file</title> <screen> <![CDATA[ /path/to/PHP_CodeSniffer/scripts/phpcs-svn-pre-commit "$REPOS" -t "$TXN" >&2 || exit 1 ]]> </screen> </example> <para> You can also use all the standard <literal>phpcs</literal> command line options to do things like set the standard to use, the tab width and the error report format: </para> <example> <title>Adding the pre-commit hook to the Subversion config file</title> <screen> <![CDATA[ /path/to/PHP_CodeSniffer/scripts/phpcs-svn-pre-commit --standard=Squiz --tab-width=4 "$REPOS" -t "$TXN" >&2 || exit 1 ]]> </screen> </example> </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 (#10970) next »