init
This commit is contained in:
29
backend/vendor/doctrine/sql-formatter/bin/regenerate-expected-output
vendored
Executable file
29
backend/vendor/doctrine/sql-formatter/bin/regenerate-expected-output
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Doctrine\SqlFormatter\CliHighlighter;
|
||||
use Doctrine\SqlFormatter\HtmlHighlighter;
|
||||
use Doctrine\SqlFormatter\NullHighlighter;
|
||||
use Doctrine\SqlFormatter\SqlFormatter;
|
||||
use Doctrine\SqlFormatter\Tests\SqlFormatterTest;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$formatter = new SqlFormatter(new HtmlHighlighter());
|
||||
|
||||
updateExpected('format-highlight.html', [$formatter, 'format']);
|
||||
updateExpected('format.txt', [new SqlFormatter(new NullHighlighter()), 'format']);
|
||||
updateExpected('highlight.html', [$formatter, 'highlight']);
|
||||
updateExpected('clihighlight.txt', [new SqlFormatter(new CliHighlighter()), 'format']);
|
||||
updateExpected('compress.txt', [$formatter, 'compress']);
|
||||
|
||||
function updateExpected(string $filename, callable $highlight): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
foreach (SqlFormatterTest::fileSqlData() as $sql) {
|
||||
$data[] = rtrim($highlight($sql), "\n");
|
||||
}
|
||||
|
||||
file_put_contents(__DIR__ . '/../tests/' . $filename, implode("\n---\n", $data) . "\n");
|
||||
}
|
||||
30
backend/vendor/doctrine/sql-formatter/bin/sql-formatter
vendored
Executable file
30
backend/vendor/doctrine/sql-formatter/bin/sql-formatter
vendored
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if("cli" !== php_sapi_name()) {
|
||||
echo "<p>Run this PHP script from the command line to see CLI syntax highlighting and formatting. It supports Unix pipes or command line argument style.</p>";
|
||||
echo "<pre><code>php bin/sql-formatter \"SELECT * FROM MyTable WHERE (id>5 AND \\`name\\` LIKE \\"testing\\");\"</code></pre>";
|
||||
echo "<pre><code>echo \"SELECT * FROM MyTable WHERE (id>5 AND \\`name\\` LIKE \\"testing\\");\" | php bin/sql-formatter</code></pre>";
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($argv[1])) {
|
||||
$sql = $argv[1];
|
||||
}
|
||||
else {
|
||||
$sql = stream_get_contents(fopen('php://stdin', 'r'));
|
||||
}
|
||||
|
||||
$autoloadFiles = [
|
||||
__DIR__ . '/../vendor/autoload.php',
|
||||
__DIR__ . '/../../../autoload.php'
|
||||
];
|
||||
|
||||
foreach ($autoloadFiles as $autoloadFile) {
|
||||
if (file_exists($autoloadFile)) {
|
||||
require_once $autoloadFile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
echo (new \Doctrine\SqlFormatter\SqlFormatter())->format($sql);
|
||||
Reference in New Issue
Block a user