Skip to content

Commit 249e834

Browse files
authored
Merge pull request #286 from nabab/patch-1
Prevent Undefined offset error
2 parents 724fa89 + 6519c03 commit 249e834

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PHPSQLParser/processors/SQLProcessor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public function process($tokens) {
6161
$skip_next = 0;
6262
$out = false;
6363

64-
$tokenCount = count($tokens);
64+
// $tokens may come as a numeric indexed array starting with an index greater than 0 (or as a boolean)
65+
$tokenCount = count($tokens);
66+
if ( is_array($tokens) ){
67+
$tokens = array_values($tokens);
68+
}
6569
for ($tokenNumber = 0; $tokenNumber < $tokenCount; ++$tokenNumber) {
6670

6771
// https://github.com/greenlion/PHP-SQL-Parser/issues/279

0 commit comments

Comments
 (0)