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
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ parameters:
count: 1
path: src/Components/ExpressionArray.php

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

-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Components\\\\FunctionCall\\:\\:\\$parameters \\(PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\|null\\) does not accept array\\<PhpMyAdmin\\\\SqlParser\\\\Component\\>\\|PhpMyAdmin\\\\SqlParser\\\\Components\\\\ArrayObj\\.$#"
count: 1
Expand Down Expand Up @@ -560,11 +555,6 @@ parameters:
count: 1
path: src/Parser.php

-
message: "#^Cannot access property \\$type on PhpMyAdmin\\\\SqlParser\\\\Token\\|null\\.$#"
count: 1
path: src/Statement.php

-
message: "#^Offset 'class' does not exist on array\\{class\\?\\: string, field\\?\\: non\\-empty\\-string, options\\?\\: array\\<string, string\\>\\}\\.$#"
count: 1
Expand Down
9 changes: 3 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@
</RedundantCondition>
</file>
<file src="src/Components/FunctionCall.php">
<MixedAssignment occurrences="1">
<code>$ret-&gt;name</code>
</MixedAssignment>
<MixedOperand occurrences="1">
<code>$token-&gt;value</code>
</MixedOperand>
<MoreSpecificImplementedParamType occurrences="1">
<code>$component</code>
</MoreSpecificImplementedParamType>
Expand Down Expand Up @@ -877,9 +877,6 @@
<MixedOperand occurrences="1">
<code>$class::build($this-&gt;$field)</code>
</MixedOperand>
<PossiblyNullPropertyFetch occurrences="1">
<code>$list-&gt;offsetGet($list-&gt;idx)-&gt;type</code>
</PossiblyNullPropertyFetch>
<PossiblyUndefinedArrayOffset occurrences="4">
<code>Parser::$KEYWORD_PARSERS[$name]['class']</code>
<code>Parser::$KEYWORD_PARSERS[$name]['field']</code>
Expand Down
13 changes: 8 additions & 5 deletions src/Components/FunctionCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =

// End of statement.
if ($token->type === Token::TYPE_DELIMITER) {
--$list->idx; // Let last token to previous one to avoid "This type of clause was previously parsed."
break;
}

Expand All @@ -87,13 +88,15 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}

if ($state === 0) {
$ret->name = $token->value;
$state = 1;
} elseif ($state === 1) {
if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) {
$ret->parameters = ArrayObj::parse($parser, $list);
if ($token->type === Token::TYPE_OPERATOR && $token->value === '(') {
--$list->idx; // ArrayObj needs to start with `(`
$state = 1;
continue;// do not add this token to the name
}

$ret->name .= $token->value;
} elseif ($state === 1) {
$ret->parameters = ArrayObj::parse($parser, $list);
break;
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace PhpMyAdmin\SqlParser;

use PhpMyAdmin\SqlParser\Components\FunctionCall;
use PhpMyAdmin\SqlParser\Components\OptionsArray;
use Stringable;

Expand Down Expand Up @@ -415,13 +414,6 @@ public function parse(Parser $parser, TokensList $list)
}

$this->after($parser, $list, $token);

// #223 Here may make a patch, if last is delimiter, back one
if ($class !== FunctionCall::class || $list->offsetGet($list->idx)->type !== Token::TYPE_DELIMITER) {
continue;
}

--$list->idx;
}

// This may be corrected by the parser.
Expand Down
8 changes: 4 additions & 4 deletions tests/Builder/CallStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testBuilderShort(): void

public function testBuilderWithDbName(): void
{
$query = 'CALL foo()';
$query = 'CALL mydb.foo()';

$parser = new Parser($query);
$stmt = $parser->statements[0];
Expand All @@ -41,7 +41,7 @@ public function testBuilderWithDbName(): void

public function testBuilderWithDbNameShort(): void
{
$query = 'CALL foo';
$query = 'CALL mydb.foo';

$parser = new Parser($query);
$stmt = $parser->statements[0];
Expand All @@ -51,12 +51,12 @@ public function testBuilderWithDbNameShort(): void

public function testBuilderWithDbNameAndParams(): void
{
$query = 'CALL foo(@bar, @baz);';
$query = 'CALL mydb.foo(@bar, @baz);';

$parser = new Parser($query);
$stmt = $parser->statements[0];

$this->assertEquals('CALL foo(@bar,@baz)', $stmt->build());
$this->assertEquals('CALL mydb.foo(@bar,@baz)', $stmt->build());
}

public function testBuilderMultiCallsShort(): void
Expand Down