10 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
11 * @link http://cweiske.de/php-sqllint.htm
16 * Textual output, easily readable by humans.
19 * @package PHP-SQLlint
21 * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
22 * @link http://www.emacswiki.org/emacs/CreatingYourOwnCompileErrorRegexp
24 class Renderer_Text implements Renderer
26 protected $fileshown = false;
27 protected $filename = null;
30 * Begin syntax check output rendering
32 * @param string $filename Path to the SQL file
36 public function startRendering($filename)
38 $this->filename = $filename;
39 $this->fileshown = false;
43 protected function showFile()
45 if ($this->fileshown) {
49 echo "Checking SQL syntax of " . $this->filename . "\n";
50 $this->fileshown = true;
54 * Show the error to the user.
56 * @param string $msg Error message
57 * @param string $token Character which caused the error
58 * @param integer $line Line at which the error occured
59 * @param integer $col Column at which the error occured
63 public function displayError($msg, $token, $line, $col)
68 . ' at "' . $this->niceToken($token) . '":'
74 * Finish syntax check output rendering; no syntax errors found
78 public function finishOk()
80 if ($this->fileshown) {
86 * Convert the token string to a readable one, especially special
87 * characters like newline and tabs
89 * @param string $str String with possibly special characters
91 * @return string Escaped string
93 protected function niceToken($str)