diff --git a/bin/sql-formatter b/bin/sql-formatter index d3079ef..9ff7331 100755 --- a/bin/sql-formatter +++ b/bin/sql-formatter @@ -1,7 +1,9 @@ #!/usr/bin/env php Run this PHP script from the command line to see CLI syntax highlighting and formatting. It supports Unix pipes or command line argument style.

"; echo "
php bin/sql-formatter \"SELECT * FROM MyTable WHERE (id>5 AND \\`name\\` LIKE \\"testing\\");\"
"; echo "
echo \"SELECT * FROM MyTable WHERE (id>5 AND \\`name\\` LIKE \\"testing\\");\" | php bin/sql-formatter
"; @@ -27,4 +29,4 @@ foreach ($autoloadFiles as $autoloadFile) { } } -echo (new \Doctrine\SqlFormatter\SqlFormatter())->format($sql); +echo (new SqlFormatter())->format($sql); diff --git a/examples/cli.php b/examples/cli.php index b924414..1023a30 100644 --- a/examples/cli.php +++ b/examples/cli.php @@ -2,6 +2,11 @@ declare(strict_types=1); +use Doctrine\SqlFormatter\SqlFormatter; +use Doctrine\SqlFormatter\Tokenizer; + +require_once __DIR__ . '/../vendor/autoload.php'; + if (PHP_SAPI !== 'cli') :?>

Run this php script from the command line to see CLI syntax highlighting and @@ -23,11 +28,6 @@ $sql = stream_get_contents($fp); } -require_once __DIR__ . '/../vendor/autoload.php'; - -use Doctrine\SqlFormatter\SqlFormatter; -use Doctrine\SqlFormatter\Tokenizer; - assert($sql !== false); echo (new SqlFormatter())->format($sql); diff --git a/examples/examples.php b/examples/examples.php index f34b55f..3c5c1a2 100644 --- a/examples/examples.php +++ b/examples/examples.php @@ -2,12 +2,12 @@ declare(strict_types=1); -require_once __DIR__ . '/../vendor/autoload.php'; - use Doctrine\SqlFormatter\NullHighlighter; use Doctrine\SqlFormatter\SqlFormatter; use Doctrine\SqlFormatter\Tokenizer; +require_once __DIR__ . '/../vendor/autoload.php'; + $formatter = new SqlFormatter(); // Example statements for formatting and highlighting diff --git a/phpcs.xml.dist b/phpcs.xml.dist index fe9fbb4..65ce6a3 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -18,13 +18,13 @@ + bin/sql-formatter examples src tests examples/*.php - tests/performance.php diff --git a/src/Tokenizer.php b/src/Tokenizer.php index 08c4cb9..b8d6d4c 100644 --- a/src/Tokenizer.php +++ b/src/Tokenizer.php @@ -849,7 +849,6 @@ private function makeRegexFromList(array $values, bool $sorted = false): string /** * Takes a SQL string and breaks it into tokens. - * Each token is an associative array with type and value. * * @param string $string The SQL string */ @@ -881,8 +880,6 @@ public function tokenize(string $string): Cursor * @param string $string The SQL string * @param string $upper The SQL string in upper case * @param Token|null $previous The result of the previous createNextToken() call - * - * @return Token An associative array containing the type and value of the token. */ private function createNextToken(string $string, string $upper, int $offset, Token|null $previous = null): Token {