Skip to content

Commit 282db99

Browse files
committed
Fix incorrect types
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent ec91b10 commit 282db99

5 files changed

Lines changed: 8 additions & 20 deletions

File tree

phpstan-baseline.neon

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,12 @@ parameters:
556556
path: src/Statements/ExplainStatement.php
557557

558558
-
559-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept mixed\\.$#"
559+
message: "#^Cannot cast mixed to string\\.$#"
560560
count: 1
561561
path: src/Statements/ExplainStatement.php
562562

563563
-
564-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$explainedColumn \\(string\\|null\\) does not accept mixed\\.$#"
564+
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\ExplainStatement\\:\\:\\$connectionId \\(int\\|null\\) does not accept mixed\\.$#"
565565
count: 1
566566
path: src/Statements/ExplainStatement.php
567567

@@ -605,11 +605,6 @@ parameters:
605605
count: 1
606606
path: src/Statements/MaintenanceStatement.php
607607

608-
-
609-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$endExpr \\(string\\|null\\) does not accept PhpMyAdmin\\\\SqlParser\\\\Components\\\\Expression\\|null\\.$#"
610-
count: 1
611-
path: src/Statements/PurgeStatement.php
612-
613608
-
614609
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\PurgeStatement\\:\\:\\$endOption \\(string\\|null\\) does not accept mixed\\.$#"
615610
count: 1

psalm-baseline.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,6 @@
784784
)]]></code>
785785
<code>ArrayObj::parse($parser, $list)</code>
786786
</PropertyTypeCoercion>
787-
<RedundantConditionGivenDocblockType>
788-
<code><![CDATA[$this->fields instanceof ArrayObj]]></code>
789-
</RedundantConditionGivenDocblockType>
790787
</file>
791788
<file src="src/Statements/DeleteStatement.php">
792789
<MixedArgument>
@@ -825,7 +822,6 @@
825822
<file src="src/Statements/ExplainStatement.php">
826823
<MixedAssignment>
827824
<code><![CDATA[$this->connectionId]]></code>
828-
<code><![CDATA[$this->explainedColumn]]></code>
829825
<code><![CDATA[$this->explainedDatabase]]></code>
830826
<code><![CDATA[$this->explainedTable]]></code>
831827
</MixedAssignment>
@@ -880,9 +876,6 @@
880876
</PossiblyUnusedProperty>
881877
</file>
882878
<file src="src/Statements/PurgeStatement.php">
883-
<ImplicitToStringCast>
884-
<code>Expression::parse($parser, $list, [])</code>
885-
</ImplicitToStringCast>
886879
<MixedAssignment>
887880
<code><![CDATA[$this->endOption]]></code>
888881
<code><![CDATA[$this->logType]]></code>

src/Statements/CreateStatement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ class CreateStatement extends Statement
378378
public function build(): string
379379
{
380380
$fields = '';
381-
if (! empty($this->fields)) {
381+
if ($this->fields !== null && $this->fields !== []) {
382382
if (is_array($this->fields)) {
383383
$fields = CreateDefinition::buildAll($this->fields) . ' ';
384-
} elseif ($this->fields instanceof ArrayObj) {
384+
} else {
385385
$fields = $this->fields->build();
386386
}
387387
}
@@ -569,7 +569,7 @@ public function parse(Parser $parser, TokensList $list): void
569569
}
570570
} else {
571571
$this->fields = CreateDefinition::parse($parser, $list);
572-
if (empty($this->fields)) {
572+
if ($this->fields === []) {
573573
$parser->error('At least one column definition was expected.', $list->tokens[$list->idx]);
574574
}
575575

src/Statements/ExplainStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ public function parse(Parser $parser, TokensList $list): void
215215
continue;
216216
}
217217

218-
if ($this->explainedColumn === null) {
219-
$this->explainedColumn = $token->value;
218+
if ($this->explainedColumn === null && $token->value !== null) {
219+
$this->explainedColumn = (string) $token->value;
220220
}
221221
}
222222
}

src/Statements/PurgeStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PurgeStatement extends Statement
3535
/**
3636
* The end expr of this query.
3737
*/
38-
public string|null $endExpr = null;
38+
public Expression|null $endExpr = null;
3939

4040
public function build(): string
4141
{

0 commit comments

Comments
 (0)