Wedge
Public area => The Pub => Off-topic => Topic started 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.
<?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($file, 30);
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.
-
Fun fact: topic about typos--- has a typo in its body 8-)
-
Yes, because you never make typos at 4am :P
-
Yes, because you never make typos at 4am :P
I said fun fact, not sad fact :P
-
or even 2 am
-
It was posted at 4.21am ;) If you're seeing any other time, your timezone settings may be wrong.
-
09:21:48 PM - remember, I'm GMT - 0700 :P
But I meant I make lots of code mistakes at 2.
-
Heh, yes, anything past midnight is when you never ever, no matter how much they beg, feed the mogwai.