Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

lint error code

  • Loading branch information...
commit 7f798f36e1c1fe285aad3ef6408379b2ed1fd784 1 parent f4660e1
@Vrtak-CZ Vrtak-CZ authored
Showing with 13 additions and 9 deletions.
  1. +13 −9 tests/lint
View
22 tests/lint
@@ -24,7 +24,7 @@ $path = $_SERVER['PWD']; // Default to execution directory
// Piped files present
-if ($files) {
+if ($files) {
foreach ($files as $file) {
checkFile("$path/$file");
}
@@ -37,7 +37,7 @@ else {
$path = $last; // snag last argument, if it wasn't an option switch
}
}
-
+
if (is_dir($path)) {
checkDirectoryContents($path);
}
@@ -57,17 +57,21 @@ if ($options['quiet']) {
echo "\n$count files checked, " . count($errors) . ' errors.';
echo "\n", implode($errors,'');
+if (count($errors)) {
+ exit(1);
+}
+
function checkDirectoryContents($dir) {
global $options, $i, $errors, $count;
-
+
$contents = scandir($dir);
foreach($contents as $content) {
if ($content == '.' || $content == '..') {
continue;
}
-
+
$path = "$dir/$content";
-
+
// Recurse into directories
if (is_dir($path) && $options['recurse']) {
checkDirectoryContents($path);
@@ -81,12 +85,12 @@ function checkDirectoryContents($dir) {
function checkFile($path) {
global $count, $errors;
// echo "$path\n";
-
+
// Skip non-php files
if (substr($path, -4) != '.php') {
return false;
}
-
+
if (($count % 60 == 0)) {
echo "\n";
}
@@ -99,7 +103,7 @@ function checkFile($path) {
else {
echo '.';
}
-
+
$count++;
}
@@ -140,7 +144,7 @@ function showHelp() {
echo <<<HELP
usage: lint [-qR] [path]
-options:
+options:
-q, --quiet: disable verbose output
-R, --recursive: recurse into subdirectories
-h, --help: display this help screen
Please sign in to comment.
Something went wrong with that request. Please try again.