Skip to content

Commit ad5f745

Browse files
committed
Correctly handle getopt failures
Signed-off-by: Michal Čihař <[email protected]>
1 parent 82e6f86 commit ad5f745

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/Utils/CLI.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function parseHighlight()
4848
$params = $this->getopt(
4949
'hq:f:', $longopts
5050
);
51+
if ($params === false) {
52+
return false;
53+
}
5154
$this->mergeLongOpts($params, $longopts);
5255
if (! isset($params['f'])) {
5356
$params['f'] = 'cli';

tests/Utils/CLITest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function highlightParams()
4848
'Usage: highlight-query --query SQL [--format html|cli|text]' . "\n",
4949
1,
5050
),
51+
array(
52+
false,
53+
'',
54+
1,
55+
),
5156
);
5257
}
5358

@@ -87,6 +92,11 @@ public function lintParams()
8792
'Usage: lint-query --query SQL' . "\n",
8893
1,
8994
),
95+
array(
96+
false,
97+
'',
98+
1,
99+
),
90100
);
91101
}
92102
}

0 commit comments

Comments
 (0)