Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ parameters:
path: src/Components/Key.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$offset \\(int\\) does not accept mixed\\.$#"
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$offset \\(int\\|string\\) does not accept mixed\\.$#"
count: 1
path: src/Components/Limit.php

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$rowCount \\(int\\) does not accept mixed\\.$#"
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\Limit\\:\\:\\$rowCount \\(int\\|string\\) does not accept mixed\\.$#"
count: 1
path: src/Components/Limit.php

Expand Down
15 changes: 9 additions & 6 deletions src/Components/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ class Limit extends Component
/**
* The number of rows skipped.
*
* @var int
* @var int|string
*/
public $offset;

/**
* The number of rows to be returned.
*
* @var int
* @var int|string
*/
public $rowCount;

/**
* @param int $rowCount the row count
* @param int $offset the offset
* @param int|string $rowCount the row count
* @param int|string $offset the offset
*/
public function __construct($rowCount = 0, $offset = 0)
{
Expand Down Expand Up @@ -88,8 +88,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
continue;
}

// Skip if not a number
if (($token->type !== Token::TYPE_NUMBER)) {
// Skip if not a number or a bind parameter (?)
if (
! ($token->type === Token::TYPE_NUMBER
|| ($token->type === Token::TYPE_SYMBOL && ($token->flags & Token::FLAG_SYMBOL_PARAMETER)))
) {
break;
}

Expand Down
1 change: 1 addition & 0 deletions tests/Misc/BugsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function bugProvider(): array
['bugs/gh412'],
['bugs/gh478'],
['bugs/gh492'],
['bugs/gh498'],
['bugs/gh499'],
['bugs/gh508'],
['bugs/gh511'],
Expand Down
4 changes: 4 additions & 0 deletions tests/data/bugs/gh498.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SELECT ?
FROM uno
JOIN dos ON dos.id = uno.id
LIMIT ? OFFSET ?
Loading