Skip to content

Commit

Permalink
Use OrderSortKeyword in GroupKeyword
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Nov 5, 2024
1 parent 913804c commit ce86c62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Components/GroupKeyword.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
final class GroupKeyword implements Component
{
/** @var 'ASC'|'DESC'|null */
public string|null $type = null;
public OrderSortKeyword|null $type = null;

/**
* The expression that is used for grouping.
Expand Down
3 changes: 2 additions & 1 deletion src/Parsers/GroupKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PhpMyAdmin\SqlParser\Parsers;

use PhpMyAdmin\SqlParser\Components\GroupKeyword;
use PhpMyAdmin\SqlParser\Components\OrderSortKeyword;
use PhpMyAdmin\SqlParser\Parseable;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\TokensList;
Expand Down Expand Up @@ -66,7 +67,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
($token->type === TokenType::Keyword)
&& (($token->keyword === 'ASC') || ($token->keyword === 'DESC'))
) {
$expr->type = $token->keyword;
$expr->type = OrderSortKeyword::from($token->keyword);
} elseif (($token->type === TokenType::Operator) && ($token->value === ',')) {

Check warning on line 71 in src/Parsers/GroupKeywords.php

View workflow job for this annotation

GitHub Actions / Mutation tests with PHP 8.2

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ } else { if ($token->type === TokenType::Keyword && ($token->keyword === 'ASC' || $token->keyword === 'DESC')) { $expr->type = OrderSortKeyword::from($token->keyword); - } elseif ($token->type === TokenType::Operator && $token->value === ',') { + } elseif ($token->type === TokenType::Operator || $token->value === ',') { if (!empty($expr->expr)) { $ret[] = $expr; }
if (! empty($expr->expr)) {
$ret[] = $expr;
Expand Down

0 comments on commit ce86c62

Please sign in to comment.