Skip to content

Commit 50de193

Browse files
Fix for trying to access array offset on value of type null (#33)
1 parent 77282ca commit 50de193

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ php:
55
- 7.0
66
- 7.1
77
- 7.2
8+
- 7.3
9+
- 7.4
810

911
script:
1012
- composer install --dev && vendor/bin/phpunit

src/php-sql-parser.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ protected function changeCaseForArrayValues($arr, $case) {
221221
/**
222222
* This class splits the SQL string into little parts, which the parser can
223223
* use to build the result array.
224-
*
224+
*
225225
* @author arothe
226226
*
227227
*/
@@ -320,7 +320,7 @@ private function balanceCharacter($tokens, $idx, $char) {
320320
/*
321321
* does the token ends with dot?
322322
* concat it with the next token
323-
*
323+
*
324324
* does the token starts with a dot?
325325
* concat it with the previous token
326326
*/
@@ -962,7 +962,7 @@ private function process_set_list($tokens) {
962962
private function process_limit($tokens) {
963963
$rowcount = "";
964964
$offset = "";
965-
965+
966966
$comma = -1;
967967
$exchange = false;
968968

@@ -994,14 +994,14 @@ private function process_limit($tokens) {
994994
$rowcount .= $tokens[$i];
995995
}
996996
}
997-
997+
998998
return array('offset' => trim($offset), 'rowcount' => trim($rowcount));
999999
}
10001000

10011001
/* This function processes the SELECT section. It splits the clauses at the commas.
10021002
Each clause is then processed by process_select_expr() and the results are added to
10031003
the expression list.
1004-
1004+
10051005
Finally, at the end, the epxression list is returned.
10061006
*/
10071007
private function process_select(&$tokens) {
@@ -1555,7 +1555,7 @@ private function process_expr_list($tokens) {
15551555
# last token is colref, const or expression
15561556
# it is an operator, in all other cases it is an all-columns-alias
15571557
# if the previous colref ends with a dot, the * is the all-columns-alias
1558-
if (!is_array($parseInfo['expr'])) {
1558+
if (!$parseInfo['expr'] || !is_array($parseInfo['expr'])) {
15591559
$parseInfo['tokenType'] = "colref"; # single or first element of select -> *
15601560
break;
15611561
}
@@ -1826,12 +1826,12 @@ private function process_into($tokens) {
18261826
}
18271827

18281828
/**
1829-
*
1830-
* This class calculates the positions
1829+
*
1830+
* This class calculates the positions
18311831
* of base_expr within the origina SQL statement.
1832-
*
1832+
*
18331833
* @author arothe
1834-
*
1834+
*
18351835
*/
18361836
class PositionCalculator extends PHPSQLParserUtils {
18371837

0 commit comments

Comments
 (0)