Skip to content

Commit 1a1930d

Browse files
committed
psalm fixes
1 parent d54b9d4 commit 1a1930d

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/FakePdoStatementTrait.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function universalExecute(?array $params = null)
129129
if ($this->realStatement) {
130130
if ($this->realStatement->execute($params) === false) {
131131
var_dump($this->sql);
132-
throw new \UnexpectedValueException($this->realStatement->errorInfo()[2]);
132+
throw new \UnexpectedValueException((string)$this->realStatement->errorInfo()[2]);
133133
}
134134
}
135135

@@ -632,6 +632,9 @@ private function getExecutedSql(?array $params) : string
632632
return $sql;
633633
}
634634

635+
/**
636+
* @return array{0: null|string, 1: int|null, 2: null|string, 3?: mixed, 4?: mixed}
637+
*/
635638
public function errorInfo(): array
636639
{
637640
return ['00000', 0, 'PHP MySQL Engine: errorInfo() not supported.'];

src/FakePdoTrait.php

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ public function quote($string, $parameter_type = \PDO::PARAM_STR)
213213
return "{$quotes[0]}{$quoted}{$quotes[1]}";
214214
}
215215

216+
/**
217+
* @return array{0: null|string, 1: int|null, 2: null|string, 3?: mixed, 4?: mixed}
218+
*/
216219
public function errorInfo(): array
217220
{
218221
return ['00000', 0, 'PHP MySQL Engine: errorInfo() not supported.'];

tests/EndToEndTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -547,15 +547,16 @@ public function testInetAtoN()
547547
$pdo = self::getPdo('mysql:foo');
548548
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
549549

550-
$query = $pdo->prepare("SELECT INET_ATON('255.255.255.255') AS a, INET_ATON('192.168.1.1') AS b, INET_ATON('127.0.0.1') AS c, INET_ATON('not an ip') AS d");
550+
$query = $pdo->prepare("SELECT INET_ATON('255.255.255.255') AS a, INET_ATON('192.168.1.1') AS b, INET_ATON('127.0.0.1') AS c, INET_ATON('not an ip') AS d, INET_ATON(NULL) as e");
551551
$query->execute();
552552
$this->assertSame(
553553
[
554554
[
555555
'a' => 4294967295,
556556
'b' => 3232235777,
557557
'c' => 2130706433,
558-
'd' => NULL
558+
'd' => NULL,
559+
'e' => NULL,
559560
],
560561
],
561562
$query->fetchAll(\PDO::FETCH_ASSOC)
@@ -568,7 +569,7 @@ public function testInetNtoA()
568569
$pdo = self::getPdo('mysql:foo');
569570
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
570571

571-
$query = $pdo->prepare("SELECT INET_NTOA(4294967295) AS a, INET_NTOA(3232235777) AS b, INET_NTOA(2130706433) AS c, INET_NTOA(NULL) as d");
572+
$query = $pdo->prepare("SELECT INET_NTOA(4294967295) AS a, INET_NTOA(3232235777) AS b, INET_NTOA(2130706433) AS c, INET_NTOA(NULL) as d, INET_NTOA('not a number') as e");
572573
$query->execute();
573574

574575
$this->assertSame(
@@ -578,6 +579,7 @@ public function testInetNtoA()
578579
'b' => '192.168.1.1',
579580
'c' => '127.0.0.1',
580581
'd' => NULL,
582+
'e' => NULL,
581583
],
582584
],
583585
$query->fetchAll(\PDO::FETCH_ASSOC)

0 commit comments

Comments
 (0)