Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove alternative executable files #594

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ The API documentation is available at
Command line utility to syntax highlight SQL query:

```sh
./vendor/bin/highlight-query --query "SELECT 1"
./vendor/bin/sql-parser --highlight --query "SELECT 1"
```

Command line utility to lint SQL query:

```sh
./vendor/bin/lint-query --query "SELECT 1"
./vendor/bin/sql-parser --lint --query "SELECT 1"
```

Command line utility to tokenize SQL query:

```sh
./vendor/bin/tokenize-query --query "SELECT 1"
./vendor/bin/sql-parser --tokenize --query "SELECT 1"
```

All commands are able to parse input from stdin (standard in), such as:

```sh
echo "SELECT 1" | ./vendor/bin/highlight-query
cat example.sql | ./vendor/bin/lint-query
echo "SELECT 1" | ./vendor/bin/sql-parser --highlight
cat example.sql | ./vendor/bin/sql-parser --lint
```

### Formatting SQL query
Expand Down Expand Up @@ -116,7 +116,7 @@ The locale is automatically detected from your environment, you can also set a d
**From cli**:

```sh
LC_ALL=pl ./vendor/bin/lint-query --query "SELECT 1"
LC_ALL=pl ./vendor/bin/sql-parser --lint --query "SELECT 1"
```

**From php**:
Expand Down
30 changes: 0 additions & 30 deletions bin/highlight-query

This file was deleted.

30 changes: 0 additions & 30 deletions bin/lint-query

This file was deleted.

30 changes: 0 additions & 30 deletions bin/tokenize-query

This file was deleted.

5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
"phpmyadmin/motranslator": "Translate messages to your favorite locale"
},
"bin": [
"bin/highlight-query",
"bin/lint-query",
"bin/sql-parser",
"bin/tokenize-query"
"bin/sql-parser"
],
"autoload": {
"psr-4": {
Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ includes:
parameters:
level: max
paths:
- bin/highlight-query
- bin/lint-query
- bin/sql-parser
- bin/tokenize-query
- src
- tests
- tools
Expand Down
3 changes: 0 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
findUnusedCode="true"
>
<projectFiles>
<file name="bin/highlight-query"/>
<file name="bin/lint-query"/>
<file name="bin/sql-parser"/>
<file name="bin/tokenize-query"/>
<directory name="src"/>
<directory name="tests"/>
<directory name="tools"/>
Expand Down
42 changes: 21 additions & 21 deletions src/Utils/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{
public function __construct()
{
Context::load();

Check warning on line 28 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ { public function __construct() { - Context::load(); + } public function run() : int {
}

public function run(): int
Expand All @@ -33,21 +33,21 @@
$params = $this->getopt('', ['lint', 'highlight', 'tokenize']);
if ($params !== false) {
if (isset($params['lint'])) {
return $this->runLint(false);
return $this->runLint();

Check warning on line 36 in src/Utils/CLI.php

View check run for this annotation

Codecov / codecov/patch

src/Utils/CLI.php#L36

Added line #L36 was not covered by tests
}

if (isset($params['highlight'])) {
return $this->runHighlight(false);
return $this->runHighlight();

Check warning on line 40 in src/Utils/CLI.php

View check run for this annotation

Codecov / codecov/patch

src/Utils/CLI.php#L40

Added line #L40 was not covered by tests
}

if (isset($params['tokenize'])) {
return $this->runTokenize(false);
return $this->runTokenize();

Check warning on line 44 in src/Utils/CLI.php

View check run for this annotation

Codecov / codecov/patch

src/Utils/CLI.php#L44

Added line #L44 was not covered by tests
}
}

$this->usageLint(false);
$this->usageHighlight(false);
$this->usageTokenize(false);
$this->usageLint();
$this->usageHighlight();
$this->usageTokenize();

Check warning on line 50 in src/Utils/CLI.php

View check run for this annotation

Codecov / codecov/patch

src/Utils/CLI.php#L48-L50

Added lines #L48 - L50 were not covered by tests

return 1;
}
Expand All @@ -56,7 +56,7 @@
* @param string[]|false[] $params
* @param string[] $longopts
*/
public function mergeLongOpts(array &$params, array &$longopts): void

Check warning on line 59 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ * @param string[]|false[] $params * @param string[] $longopts */ - public function mergeLongOpts(array &$params, array &$longopts) : void + protected function mergeLongOpts(array &$params, array &$longopts) : void { foreach ($longopts as $value) { $value = rtrim($value, ':');
{
foreach ($longopts as $value) {
$value = rtrim($value, ':');
Expand All @@ -68,9 +68,9 @@
}
}

public function usageHighlight(bool $isStandalone = true): void
public function usageHighlight(): void

Check warning on line 71 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ $params[$value[0]] = $params[$value]; } } - public function usageHighlight() : void + protected function usageHighlight() : void { $command = 'sql-parser --highlight'; echo 'Usage: ' . $command . ' --query SQL [--format html|cli|text] [--ansi]' . "\n";
{
$command = $isStandalone ? 'highlight-query' : 'sql-parser --highlight';
$command = 'sql-parser --highlight';

echo 'Usage: ' . $command . ' --query SQL [--format html|cli|text] [--ansi]' . "\n";
echo ' cat file.sql | ' . $command . "\n";
Expand All @@ -87,9 +87,9 @@
}

/** @return string[]|false[]|false */
public function parseHighlight(): array|false

Check warning on line 90 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ return getopt($opt, $long); } /** @return string[]|false[]|false */ - public function parseHighlight() : array|false + protected function parseHighlight() : array|false { $longopts = ['help', 'query:', 'format:', 'ansi']; $params = $this->getopt('hq:f:a', $longopts);
{
$longopts = [

Check warning on line 92 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ /** @return string[]|false[]|false */ public function parseHighlight() : array|false { - $longopts = ['help', 'query:', 'format:', 'ansi']; + $longopts = ['query:', 'format:', 'ansi']; $params = $this->getopt('hq:f:a', $longopts); if ($params === false) { return false;
'help',
'query:',
'format:',
Expand All @@ -114,15 +114,15 @@
return $params;
}

public function runHighlight(bool $isStandalone = true): int
public function runHighlight(): int
{
$params = $this->parseHighlight();
if ($params === false) {
return 1;
}

if (isset($params['h'])) {
$this->usageHighlight($isStandalone);
$this->usageHighlight();

return 0;
}
Expand Down Expand Up @@ -150,23 +150,23 @@
}

echo "ERROR: Missing parameters!\n";
$this->usageHighlight($isStandalone);
$this->usageHighlight();

return 1;
}

public function usageLint(bool $isStandalone = true): void
public function usageLint(): void

Check warning on line 158 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ $this->usageHighlight(); return 1; } - public function usageLint() : void + protected function usageLint() : void { $command = 'sql-parser --lint'; echo 'Usage: ' . $command . ' --query SQL [--ansi]' . "\n";
{
$command = $isStandalone ? 'lint-query' : 'sql-parser --lint';
$command = 'sql-parser --lint';

echo 'Usage: ' . $command . ' --query SQL [--ansi]' . "\n";
echo ' cat file.sql | ' . $command . "\n";
}

/** @return string[]|false[]|false */
public function parseLint(): array|false

Check warning on line 167 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ echo ' cat file.sql | ' . $command . "\n"; } /** @return string[]|false[]|false */ - public function parseLint() : array|false + protected function parseLint() : array|false { $longopts = ['help', 'query:', 'context:', 'ansi']; $params = $this->getopt('hq:c:a', $longopts);
{
$longopts = [

Check warning on line 169 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ /** @return string[]|false[]|false */ public function parseLint() : array|false { - $longopts = ['help', 'query:', 'context:', 'ansi']; + $longopts = ['query:', 'context:', 'ansi']; $params = $this->getopt('hq:c:a', $longopts); if ($params === false) { return false;
'help',
'query:',
'context:',
Expand All @@ -182,21 +182,21 @@
return $params;
}

public function runLint(bool $isStandalone = true): int
public function runLint(): int
{
$params = $this->parseLint();
if ($params === false) {
return 1;
}

if (isset($params['h'])) {
$this->usageLint($isStandalone);
$this->usageLint();

return 0;
}

if (isset($params['c'])) {
Context::load($params['c']);

Check warning on line 199 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ return 0; } if (isset($params['c'])) { - Context::load($params['c']); + } if (!isset($params['q'])) { $stdIn = $this->readStdin();
}

if (! isset($params['q'])) {
Expand All @@ -212,7 +212,7 @@
}

if (isset($params['q'])) {
$lexer = new Lexer($params['q'], false);

Check warning on line 215 in src/Utils/CLI.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "FalseValue": --- Original +++ New @@ @@ Context::setMode(Context::SQL_MODE_ANSI_QUOTES); } if (isset($params['q'])) { - $lexer = new Lexer($params['q'], false); + $lexer = new Lexer($params['q'], true); $parser = new Parser($lexer->list); $errors = Error::get([$lexer, $parser]); if ($errors === []) {
$parser = new Parser($lexer->list);
$errors = Error::get([$lexer, $parser]);
if ($errors === []) {
Expand All @@ -227,14 +227,14 @@
}

echo "ERROR: Missing parameters!\n";
$this->usageLint($isStandalone);
$this->usageLint();

return 1;
}

public function usageTokenize(bool $isStandalone = true): void
public function usageTokenize(): void
{
$command = $isStandalone ? 'tokenize-query' : 'sql-parser --tokenize';
$command = 'sql-parser --tokenize';

echo 'Usage: ' . $command . ' --query SQL [--ansi]' . "\n";
echo ' cat file.sql | ' . $command . "\n";
Expand All @@ -258,15 +258,15 @@
return $params;
}

public function runTokenize(bool $isStandalone = true): int
public function runTokenize(): int
{
$params = $this->parseTokenize();
if ($params === false) {
return 1;
}

if (isset($params['h'])) {
$this->usageTokenize($isStandalone);
$this->usageTokenize();

return 0;
}
Expand Down Expand Up @@ -302,7 +302,7 @@
}

echo "ERROR: Missing parameters!\n";
$this->usageTokenize($isStandalone);
$this->usageTokenize();

return 1;
}
Expand Down
Loading
Loading