GeezerVison is showing github.com — Fix #156 - Parser mistakes with comments · phpmyadmin/sql-parser@8090cb1
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/Components/Expression.php +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -154,6 +154,7 @@ public function __construct($database = null, $table = null, $column = null, $al | 154 | 154 | * @param array $options parameters for parsing | 155 | 155 | * | 156 | 156 | * @return Expression|null | | 157 | + * @throws \PhpMyAdmin\SqlParser\Exceptions\ParserException | 157 | 158 | */ | 158 | 159 | public static function parse(Parser $parser, TokensList $list, array $options = array()) | 159 | 160 | { | |
Collapse file Copy file name to clipboardExpand all lines: src/Components/ExpressionArray.php +12-2Lines changed: 12 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,6 +26,7 @@ class ExpressionArray extends Component | 26 | 26 | * @param array $options parameters for parsing | 27 | 27 | * | 28 | 28 | * @return Expression[] | | 29 | + * @throws \PhpMyAdmin\SqlParser\Exceptions\ParserException | 29 | 30 | */ | 30 | 31 | public static function parse(Parser $parser, TokensList $list, array $options = array()) | 31 | 32 | { | @@ -106,12 +107,21 @@ public static function parse(Parser $parser, TokensList $list, array $options = | 106 | 107 |
| 107 | 108 | --$list->idx; | 108 | 109 |
| | 110 | + // TODO verify #156 Hotfix | | 111 | + if (is_array($ret)) { | | 112 | + $expr = $ret[count($ret) - 1]->expr; | | 113 | + if (preg_match('/\s*--\s.*$/', $expr, $matches)) { | | 114 | + $found = $matches[0]; | | 115 | + $ret[count($ret) - 1]->expr = substr($expr, 0, strlen($expr) - strlen($found)); | | 116 | + } | | 117 | + } | | 118 | + | 109 | 119 | return $ret; | 110 | 120 | } | 111 | 121 |
| 112 | 122 | /** | 113 | | - * @param ExpressionArray[] $component the component to be built | 114 | | - * @param array $options parameters for building | | 123 | + * @param Expression[] $component the component to be built | | 124 | + * @param array $options parameters for building | 115 | 125 | * | 116 | 126 | * @return string | 117 | 127 | */ | |
Collapse file Copy file name to clipboardExpand all lines: src/Parser.php +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -379,6 +379,7 @@ public function __construct($list = null, $strict = false) | 379 | 379 |
| 380 | 380 | /** | 381 | 381 | * Builds the parse trees. | | 382 | + * @throws ParserException | 382 | 383 | */ | 383 | 384 | public function parse() | 384 | 385 | { | |
Collapse file Copy file name to clipboardExpand all lines: src/Statement.php +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -193,6 +193,7 @@ public function build() | 193 | 193 | * | 194 | 194 | * @param Parser $parser the instance that requests parsing | 195 | 195 | * @param TokensList $list the list of tokens to be parsed | | 196 | + * @throws Exceptions\ParserException | 196 | 197 | */ | 197 | 198 | public function parse(Parser $parser, TokensList $list) | 198 | 199 | { | @@ -472,6 +473,7 @@ public function __toString() | 472 | 473 | * @param TokensList $list the list of tokens to be parsed | 473 | 474 | * | 474 | 475 | * @return bool | | 476 | + * @throws Exceptions\ParserException | 475 | 477 | */ | 476 | 478 | public function validateClauseOrder($parser, $list) | 477 | 479 | { | |
|