Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Lint checker
« 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.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Lint checker
« Reply #1, on March 23rd, 2013, 12:10 PM »
Fun fact: topic about typos--- has a typo in its body 8-)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Lint checker
« Reply #2, on March 23rd, 2013, 02:33 PM »
Yes, because you never make typos at 4am :P

Nao

  • Dadman with a boy
  • Posts: 16,082

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Lint checker
« Reply #5, 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.

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Re: Lint checker
« Reply #6, 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.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Lint checker
« Reply #7, 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.