-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathpdo-stmt-obj-type.php
More file actions
35 lines (27 loc) · 999 Bytes
/
Copy pathpdo-stmt-obj-type.php
File metadata and controls
35 lines (27 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace PdoStmtObjectTypeTest;
use PDO;
use PDOStatement;
use function PHPStan\Testing\assertType;
use staabm\PHPStanDba\Tests\Fixture\MyRowClass;
class Foo
{
/**
* @return PDOStatement<array{email: string, 0: string, adaid: int<0, 4294967295>, 1: int<0, 4294967295>}>
*/
private function prepare(PDO $pdo): PDOStatement {
return $pdo->prepare('SELECT email, adaid FROM ada');
}
public function fetch(PDO $pdo)
{
$stmt = $this->prepare($pdo);
$stmt->execute();
assertType('PDOStatement<array{email: string, 0: string, adaid: int<0, 4294967295>, 1: int<0, 4294967295>}>', $stmt);
$all = $stmt->fetch(PDO::FETCH_NUM);
assertType('array{string, int<0, 4294967295>}|false', $all);
$all = $stmt->fetch(PDO::FETCH_ASSOC);
assertType('array{email: string, adaid: int<0, 4294967295>}|false', $all);
$all = $stmt->fetch(PDO::FETCH_COLUMN);
assertType('string|false', $all);
}
}