Wedge

Public area => The Pub => Off-topic => Topic started by: Arantor on March 23rd, 2013, 05:21 AM

Title: Lint checker
Post by: Arantor on March 23rd, 2013, 05:21 AM
OK, so it's very, very quick and dirty - something like 10 minutes work here to write and test. But it's useful, I through it at the entire SVN repo and it checks the syntax of files. Very handy if I've made a big change and need to syntax check it.

I even found a bug with it just now.

Code: [Select]
<?php

$base_path 
'C:/Dev/public_html/wedge/trunk';
$php 'C:/wamp/bin/php/php5.3.10/php.exe';

$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($base_path), RecursiveIteratorIterator::SELF_FIRST);
foreach(
$objects as $name => $object){
if (is_file($name) && substr($name, -4) == '.php')
$filelist[] = $name;
}

$success = array();
$failure = array();

foreach (
$filelist as $file)
{
$result shell_exec($php ' -l ' $file);

$file substr($file30);

if (trim($result) == '')
continue;
elseif (strpos($result'No syntax errors') === 0)
$success[] = $file;
else
echo $file'<br>'$result'<br><br>';

flush();
}

echo 
'<hr>The following files were all successful:<br>'implode('<br>'$success);

You will likely need to change the paths to suit yourself though.
Title: Re: Lint checker
Post by: Nao on March 23rd, 2013, 12:10 PM
Fun fact: topic about typos--- has a typo in its body 8-)
Title: Re: Lint checker
Post by: Arantor on March 23rd, 2013, 02:33 PM
Yes, because you never make typos at 4am :P
Title: Re: Lint checker
Post by: Nao on March 23rd, 2013, 02:45 PM
Quote from Arantor on March 23rd, 2013, 02:33 PM
Yes, because you never make typos at 4am :P
I said fun fact, not sad fact :P
Title: Re: Lint checker
Post by: live627 on March 23rd, 2013, 11:06 PM
or even 2 am
Title: Re: Lint checker
Post by: Arantor on March 23rd, 2013, 11:20 PM
It was posted at 4.21am ;) If you're seeing any other time, your timezone settings may be wrong.
Title: Re: Lint checker
Post by: live627 on March 23rd, 2013, 11:36 PM
09:21:48 PM - remember, I'm GMT - 0700 :P

But I meant I make lots of code mistakes at 2.
Title: Re: Lint checker
Post by: Arantor on March 23rd, 2013, 11:39 PM
Heh, yes, anything past midnight is when you never ever, no matter how much they beg, feed the mogwai.