<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for devhands</title>
	<atom:link href="http://www.devhands.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devhands.com</link>
	<description>Inspired by consistent circumstances</description>
	<lastBuildDate>Tue, 09 Mar 2010 06:49:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Subversion hook php framework by Adam</title>
		<link>http://www.devhands.com/2010/01/subversion-hook-php-framework-in/comment-page-1/#comment-10578</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Tue, 09 Mar 2010 06:49:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=422#comment-10578</guid>
		<description>Thanks so much, this works great! Following your example, it was very easy to edit your tests and add my own. I added a test that verifies PHP syntax is correct before committing (for certain file extensions only), and also added some logic that will copy the committed files to a specific location for further testing (only if all other tests pass. I wanted to run this copy action in the postcommit hook, but the CommitTests class doesn&#039;t seem to work properly in the postcommit hook. Specifically, it doesn&#039;t seem to know what files were committed).

Here&#039;s the method to check syntax:

***********************

class CommitTests
{

    [...snip...]

    //path to php binary
    public static $PHP = &quot;/usr/local/php-cgi/bin/php&quot;;

    /**
     * Tests if the committed files pass PHP syntax checking
     *
     * @param string $msg error messages placeholder
     * @param array $filetypes array of file types which should be tested
     * @return bool
     */
    protected function _testPHPSyntax(&amp;$msg, array $filetypes=array()){
    	$result = true;
        $files = $this-&gt;_getChangedFiles($filetypes);
        
        $tempDir = sys_get_temp_dir();
        foreach ($files as $file =&gt; $extension) {
			$content = $this-&gt;_getFileContent($file);
			
			$tempfile = tempnam($tempDir, &quot;stax_&quot;);
			file_put_contents($tempfile, $content);
			$tempfile = realpath($tempfile); //sort out the formatting of the filename

			$output = shell_exec(self::$PHP.&#039; -l &quot;&#039;.$tempfile.&#039;&quot;&#039;);
			
			//try to find a parse error text and chop it off
			$syntaxErrorMsg = preg_replace(&quot;/Errors parsing.*$/&quot;, &quot;&quot;, $output, -1, $count);
            if ($count &gt; 0) { //found errors
                $result = false;
                $syntaxErrorMsg = str_replace($tempfile,$file,$syntaxErrorMsg); //replace temp filename with real filename
                $msg .= &quot;\t[$file] PHP Syntax error in file. Message: $syntaxErrorMsg\n&quot;;
            }
            
            unlink($tempfile);
        }

        return $result;
    }
    
    [...snip...]
}

***********************

And run it with:

new CommitTests($argv[1], $argv[2], array(
    &#039;PHPSyntax&#039;=&gt;array(array(&#039;php&#039;)), //array contains file extensions to check
    ....etc....
));

***********************

Thanks so much for sharing! This framework saved me a lot of time.
Adam</description>
		<content:encoded><![CDATA[<p>Thanks so much, this works great! Following your example, it was very easy to edit your tests and add my own. I added a test that verifies PHP syntax is correct before committing (for certain file extensions only), and also added some logic that will copy the committed files to a specific location for further testing (only if all other tests pass. I wanted to run this copy action in the postcommit hook, but the CommitTests class doesn&#8217;t seem to work properly in the postcommit hook. Specifically, it doesn&#8217;t seem to know what files were committed).</p>
<p>Here&#8217;s the method to check syntax:</p>
<p>***********************</p>
<p>class CommitTests<br />
{</p>
<p>    [...snip...]</p>
<p>    //path to php binary<br />
    public static $PHP = &#8220;/usr/local/php-cgi/bin/php&#8221;;</p>
<p>    /**<br />
     * Tests if the committed files pass PHP syntax checking<br />
     *<br />
     * @param string $msg error messages placeholder<br />
     * @param array $filetypes array of file types which should be tested<br />
     * @return bool<br />
     */<br />
    protected function _testPHPSyntax(&amp;$msg, array $filetypes=array()){<br />
    	$result = true;<br />
        $files = $this-&gt;_getChangedFiles($filetypes);</p>
<p>        $tempDir = sys_get_temp_dir();<br />
        foreach ($files as $file =&gt; $extension) {<br />
			$content = $this-&gt;_getFileContent($file);</p>
<p>			$tempfile = tempnam($tempDir, &#8220;stax_&#8221;);<br />
			file_put_contents($tempfile, $content);<br />
			$tempfile = realpath($tempfile); //sort out the formatting of the filename</p>
<p>			$output = shell_exec(self::$PHP.&#8217; -l &#8220;&#8216;.$tempfile.&#8217;&#8221;&#8216;);</p>
<p>			//try to find a parse error text and chop it off<br />
			$syntaxErrorMsg = preg_replace(&#8220;/Errors parsing.*$/&#8221;, &#8220;&#8221;, $output, -1, $count);<br />
            if ($count &gt; 0) { //found errors<br />
                $result = false;<br />
                $syntaxErrorMsg = str_replace($tempfile,$file,$syntaxErrorMsg); //replace temp filename with real filename<br />
                $msg .= &#8220;\t[$file] PHP Syntax error in file. Message: $syntaxErrorMsg\n&#8221;;<br />
            }</p>
<p>            unlink($tempfile);<br />
        }</p>
<p>        return $result;<br />
    }</p>
<p>    [...snip...]<br />
}</p>
<p>***********************</p>
<p>And run it with:</p>
<p>new CommitTests($argv[1], $argv[2], array(<br />
    &#8216;PHPSyntax&#8217;=&gt;array(array(&#8216;php&#8217;)), //array contains file extensions to check<br />
    &#8230;.etc&#8230;.<br />
));</p>
<p>***********************</p>
<p>Thanks so much for sharing! This framework saved me a lot of time.<br />
Adam</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on mod_rewrite server-variables full list by Juan</title>
		<link>http://www.devhands.com/2008/11/mod_rewrite-server-variables-full-list/comment-page-1/#comment-10209</link>
		<dc:creator>Juan</dc:creator>
		<pubDate>Mon, 22 Feb 2010 15:18:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=109#comment-10209</guid>
		<description>Very useful for debuggin Rewrite Conditions and Rules.</description>
		<content:encoded><![CDATA[<p>Very useful for debuggin Rewrite Conditions and Rules.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Gunnar Optics glasses &#8211; if you need something yellow in front of your face by Aleksandr Tsertkov</title>
		<link>http://www.devhands.com/2008/11/gunnar-optics-glasses-if-you-need-something-yellow-in-front-of-your-face/comment-page-1/#comment-9796</link>
		<dc:creator>Aleksandr Tsertkov</dc:creator>
		<pubDate>Mon, 08 Feb 2010 09:46:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=120#comment-9796</guid>
		<description>Nice! How much did u pay?</description>
		<content:encoded><![CDATA[<p>Nice! How much did u pay?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Gunnar Optics glasses &#8211; if you need something yellow in front of your face by Andy</title>
		<link>http://www.devhands.com/2008/11/gunnar-optics-glasses-if-you-need-something-yellow-in-front-of-your-face/comment-page-1/#comment-9598</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Mon, 01 Feb 2010 20:59:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=120#comment-9598</guid>
		<description>I bought some, they do work.   I get migraines if I stare at a computer screen for a long period of time but the gunners prevent that</description>
		<content:encoded><![CDATA[<p>I bought some, they do work.   I get migraines if I stare at a computer screen for a long period of time but the gunners prevent that</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Javascript function(){}() vs (function(){})() by Kuroki Kaze</title>
		<link>http://www.devhands.com/2009/05/javascript-function-vs-function/comment-page-1/#comment-7036</link>
		<dc:creator>Kuroki Kaze</dc:creator>
		<pubDate>Thu, 29 Oct 2009 13:24:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=354#comment-7036</guid>
		<description>Thanks for clarification :) I recently read about anonymous functions in Resig&#039;s &quot;Pro Javascript Techniques&quot;, but haven&#039;t thought about it.

Also matt, kudos for documentation link :)</description>
		<content:encoded><![CDATA[<p>Thanks for clarification <img src='http://www.devhands.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I recently read about anonymous functions in Resig&#8217;s &#8220;Pro Javascript Techniques&#8221;, but haven&#8217;t thought about it.</p>
<p>Also matt, kudos for documentation link <img src='http://www.devhands.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.2.10 comes with a broken PEAR by Kuroki Kaze</title>
		<link>http://www.devhands.com/2009/08/php-5-2-10-broken-pear/comment-page-1/#comment-7034</link>
		<dc:creator>Kuroki Kaze</dc:creator>
		<pubDate>Thu, 29 Oct 2009 12:58:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=388#comment-7034</guid>
		<description>5.2.11 is susceptible too.</description>
		<content:encoded><![CDATA[<p>5.2.11 is susceptible too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on PHP 5.3.0 open_basedir bug by Lexa</title>
		<link>http://www.devhands.com/2009/09/php-5-3-0-open_basedir-bug/comment-page-1/#comment-6606</link>
		<dc:creator>Lexa</dc:creator>
		<pubDate>Thu, 08 Oct 2009 15:14:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=400#comment-6606</guid>
		<description>BD post ))))</description>
		<content:encoded><![CDATA[<p>BD post ))))</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Serving website with and wihout &#8220;www&#8221; prefix by hachik</title>
		<link>http://www.devhands.com/2008/09/serving-website-with-and-wihout-www-prefix/comment-page-1/#comment-5345</link>
		<dc:creator>hachik</dc:creator>
		<pubDate>Thu, 20 Aug 2009 20:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=26#comment-5345</guid>
		<description>I use for apache 1.3 following rewrite condition:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}$1 [R=301,L]</description>
		<content:encoded><![CDATA[<p>I use for apache 1.3 following rewrite condition:</p>
<p>RewriteEngine On<br />
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]<br />
RewriteRule ^(.*)$ <a href="http://www.%" rel="nofollow">http://www.%</a>{HTTP_HOST}$1 [R=301,L]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on No gettext support for PHP5 in Gentoo by Paul</title>
		<link>http://www.devhands.com/2008/08/no-gettext-support-for-php5-in-gentoo/comment-page-1/#comment-3647</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Sat, 30 May 2009 14:41:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=22#comment-3647</guid>
		<description>Thanks!</description>
		<content:encoded><![CDATA[<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Javascript function(){}() vs (function(){})() by Alexandr Chertkov</title>
		<link>http://www.devhands.com/2009/05/javascript-function-vs-function/comment-page-1/#comment-3499</link>
		<dc:creator>Alexandr Chertkov</dc:creator>
		<pubDate>Tue, 26 May 2009 08:21:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.devhands.com/?p=354#comment-3499</guid>
		<description>Thanks for the link Matt!</description>
		<content:encoded><![CDATA[<p>Thanks for the link Matt!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
