no text output when all is fine
authorChristian Weiske <cweiske@cweiske.de>
Mon, 14 Dec 2015 14:15:54 +0000 (15:15 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 14 Dec 2015 14:15:54 +0000 (15:15 +0100)
src/phpsqllint/Renderer/Text.php

index c36e76841f1c29221c1d98c9815ff766b59e31b3..44e7ecbd4ea61ed7ab7e789f0d702a7f96b5f313 100644 (file)
@@ -23,6 +23,9 @@ namespace phpsqllint;
  */
 class Renderer_Text implements Renderer
 {
  */
 class Renderer_Text implements Renderer
 {
+    protected $fileshown = false;
+    protected $filename = null;
+
     /**
      * Begin syntax check output rendering
      *
     /**
      * Begin syntax check output rendering
      *
@@ -32,7 +35,19 @@ class Renderer_Text implements Renderer
      */
     public function startRendering($filename)
     {
      */
     public function startRendering($filename)
     {
-        echo "Checking SQL syntax of " . $filename . "\n";
+        $this->filename  = $filename;
+        $this->fileshown = false;
+    }
+
+
+    protected function showFile()
+    {
+        if ($this->fileshown) {
+            return;
+        }
+
+        echo "Checking SQL syntax of " . $this->filename . "\n";
+        $this->fileshown = true;
     }
 
     /**
     }
 
     /**
@@ -47,6 +62,7 @@ class Renderer_Text implements Renderer
      */
     public function displayError($msg, $token, $line, $col)
     {
      */
     public function displayError($msg, $token, $line, $col)
     {
+        $this->showFile();
         echo ' Line ' . $line
             . ', col ' . $col
             . ' at "' . $this->niceToken($token) . '":'
         echo ' Line ' . $line
             . ', col ' . $col
             . ' at "' . $this->niceToken($token) . '":'
@@ -61,7 +77,9 @@ class Renderer_Text implements Renderer
      */
     public function finishOk()
     {
      */
     public function finishOk()
     {
-        echo " OK\n";
+        if ($this->fileshown) {
+            echo " OK\n";
+        }
     }
 
     /**
     }
 
     /**