Skip to content

Commit 89835fb

Browse files
Merge pull request #18721 from kamil-tekiela/TokensList
Fix TokensList usages
2 parents cd0d116 + fc3b6a3 commit 89835fb

5 files changed

Lines changed: 3 additions & 29 deletions

File tree

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8295,11 +8295,6 @@ parameters:
82958295
count: 1
82968296
path: src/Controllers/View/CreateController.php
82978297

8298-
-
8299-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$body \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Token\\>\\|string\\) in isset\\(\\) is not nullable\\.$#"
8300-
count: 1
8301-
path: src/Controllers/View/CreateController.php
8302-
83038298
-
83048299
message: "#^Cannot access offset 'back' on mixed\\.$#"
83058300
count: 1
@@ -18945,11 +18940,6 @@ parameters:
1894518940
count: 1
1894618941
path: src/Tracking/Tracker.php
1894718942

18948-
-
18949-
message: "#^Cannot access property \\$value on PhpMyAdmin\\\\SqlParser\\\\Token\\|string\\.$#"
18950-
count: 3
18951-
path: src/Tracking/Tracker.php
18952-
1895318943
-
1895418944
message: "#^Cannot cast mixed to string\\.$#"
1895518945
count: 1

psalm-baseline.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4422,9 +4422,6 @@
44224422
<DeprecatedMethod>
44234423
<code>Config::getInstance()</code>
44244424
</DeprecatedMethod>
4425-
<DocblockTypeContradiction>
4426-
<code><![CDATA[$viewData['as']]]></code>
4427-
</DocblockTypeContradiction>
44284425
<MixedArgument>
44294426
<code>$db</code>
44304427
<code>$table</code>
@@ -4441,7 +4438,6 @@
44414438
<code>$db</code>
44424439
<code>$table</code>
44434440
<code><![CDATA[$viewData['as']]]></code>
4444-
<code><![CDATA[$viewData['as']]]></code>
44454441
<code><![CDATA[$viewData['definer']]]></code>
44464442
<code><![CDATA[$viewData['sql_security']]]></code>
44474443
<code><![CDATA[$viewData['with']]]></code>
@@ -4456,9 +4452,6 @@
44564452
<PossiblyUnusedMethod>
44574453
<code>__construct</code>
44584454
</PossiblyUnusedMethod>
4459-
<RedundantConditionGivenDocblockType>
4460-
<code><![CDATA[isset($stmt->body)]]></code>
4461-
</RedundantConditionGivenDocblockType>
44624455
</file>
44634456
<file src="src/Controllers/View/OperationsController.php">
44644457
<DeprecatedMethod>
@@ -12475,9 +12468,6 @@
1247512468
<code>self::$trackingCache[$dbName][$tableName]</code>
1247612469
</MixedReturnStatement>
1247712470
<PossiblyInvalidPropertyFetch>
12478-
<code><![CDATA[$statement->body[2]->value]]></code>
12479-
<code><![CDATA[$statement->body[3]->value]]></code>
12480-
<code><![CDATA[$statement->body[4]->value]]></code>
1248112471
<code><![CDATA[$statement->into->dest->table]]></code>
1248212472
</PossiblyInvalidPropertyFetch>
1248312473
<PossiblyNullArrayAccess>

src/Controllers/View/CreateController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function __invoke(ServerRequest $request): void
176176
$parser = new Parser($createView);
177177
/** @var CreateStatement $stmt */
178178
$stmt = $parser->statements[0];
179-
$viewData['as'] = isset($stmt->body) ? TokensList::build($stmt->body) : $viewData['as'];
179+
$viewData['as'] = TokensList::buildFromArray($stmt->body);
180180
}
181181
}
182182

src/Database/Routines.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public function getDataFromName(string $name, string $type, bool $all = true): a
438438
$stmt = $parser->statements[0];
439439

440440
// Do not use $routine['ROUTINE_DEFINITION'] because of a MySQL escaping issue: #15370
441-
$body = TokensList::build($stmt->body);
441+
$body = TokensList::buildFromArray($stmt->body);
442442
if ($body === '') {
443443
// Fallback just in case the parser fails
444444
$body = (string) $routine['ROUTINE_DEFINITION'];

src/Plugins/Export/ExportSql.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2571,13 +2571,7 @@ public function replaceWithAliases(
25712571
) {
25722572
// Replacing the body.
25732573
/** @infection-ignore-all */
2574-
for ($i = 0, $count = count((array) $statement->body); $i < $count; ++$i) {
2575-
2576-
/**
2577-
* Token parsed at this moment.
2578-
*
2579-
* @var Token $token
2580-
*/
2574+
for ($i = 0, $count = count($statement->body); $i < $count; ++$i) {
25812575
$token = $statement->body[$i];
25822576

25832577
// Replacing only symbols (that are not variables) and unknown

0 commit comments

Comments
 (0)