Skip to content

Commit 186736a

Browse files
clxmstaabstaabm
authored andcommitted
added failling PdoStatementObjectType test
1 parent e435a38 commit 186736a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace PdoStmtObjectTypeTest;
4+
5+
use PDO;
6+
use PDOStatement;
7+
use function PHPStan\Testing\assertType;
8+
use staabm\PHPStanDba\Tests\Fixture\MyRowClass;
9+
10+
class Foo
11+
{
12+
/**
13+
* @return PDOStatement<array{email: string, 0: string, adaid: int<0, 4294967295>, 1: int<0, 4294967295>}>
14+
*/
15+
private function prepare(PDO $pdo): PDOStatement {
16+
return $pdo->prepare('SELECT email, adaid FROM ada');
17+
}
18+
19+
public function fetch(PDO $pdo)
20+
{
21+
$stmt = $this->prepare($pdo);
22+
$stmt->execute();
23+
24+
assertType('PDOStatement<array{email: string, 0: string, adaid: int<0, 4294967295>, 1: int<0, 4294967295>}>', $stmt);
25+
26+
$all = $stmt->fetch(PDO::FETCH_NUM);
27+
assertType('array{string, int<0, 4294967295>}|false', $all);
28+
29+
$all = $stmt->fetch(PDO::FETCH_ASSOC);
30+
assertType('array{email: string, adaid: int<0, 4294967295>}|false', $all);
31+
32+
$all = $stmt->fetch(PDO::FETCH_COLUMN);
33+
assertType('string|false', $all);
34+
}
35+
}

0 commit comments

Comments
 (0)