Skip to content

Commit

Permalink
Fix for trying to access array offset on value of type null (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
ingluisjimenez authored Mar 6, 2020
1 parent 77282ca commit 50de193
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

script:
- composer install --dev && vendor/bin/phpunit
20 changes: 10 additions & 10 deletions src/php-sql-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected function changeCaseForArrayValues($arr, $case) {
/**
* This class splits the SQL string into little parts, which the parser can
* use to build the result array.
*
*
* @author arothe
*
*/
Expand Down Expand Up @@ -320,7 +320,7 @@ private function balanceCharacter($tokens, $idx, $char) {
/*
* does the token ends with dot?
* concat it with the next token
*
*
* does the token starts with a dot?
* concat it with the previous token
*/
Expand Down Expand Up @@ -962,7 +962,7 @@ private function process_set_list($tokens) {
private function process_limit($tokens) {
$rowcount = "";
$offset = "";

$comma = -1;
$exchange = false;

Expand Down Expand Up @@ -994,14 +994,14 @@ private function process_limit($tokens) {
$rowcount .= $tokens[$i];
}
}

return array('offset' => trim($offset), 'rowcount' => trim($rowcount));
}

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

/**
*
* This class calculates the positions
*
* This class calculates the positions
* of base_expr within the origina SQL statement.
*
*
* @author arothe
*
*
*/
class PositionCalculator extends PHPSQLParserUtils {

Expand Down

0 comments on commit 50de193

Please sign in to comment.