1+ <?php
2+
3+ namespace DoctrineDbal3Test ;
4+
5+ use Doctrine \DBAL \Connection ;
6+ use function PHPStan \Testing \assertType ;
7+
8+ class Foo
9+ {
10+ public function resultFetching (Connection $ conn )
11+ {
12+ $ result = $ conn ->query ('SELECT email, adaid FROM ada ' );
13+
14+ $ columnCount = $ result ->columnCount ();
15+ assertType ('2 ' , $ columnCount );
16+
17+ $ fetch = $ result ->fetchOne ();
18+ assertType ('string|false ' , $ fetch );
19+
20+ $ fetch = $ result ->fetchNumeric ();
21+ assertType ('array{string, int<-32768, 32767>}|false ' , $ fetch );
22+
23+ $ fetch = $ result ->fetchFirstColumn ();
24+ assertType ('list<string> ' , $ fetch );
25+
26+ $ fetch = $ result ->fetchAssociative ();
27+ assertType ('array{email: string, adaid: int<-32768, 32767>}|false ' , $ fetch );
28+
29+ $ fetch = $ result ->fetchAllNumeric ();
30+ assertType ('list<array{string, int<-32768, 32767>}> ' , $ fetch );
31+
32+ $ fetch = $ result ->fetchAllAssociative ();
33+ assertType ('list<array{email: string, adaid: int<-32768, 32767>}> ' , $ fetch );
34+
35+ $ fetch = $ result ->fetchAllKeyValue ();
36+ assertType ('array<string, int<-32768, 32767>> ' , $ fetch );
37+
38+ $ fetch = $ result ->iterateNumeric ();
39+ assertType ('Traversable<int, array{string, int<-32768, 32767>}> ' , $ fetch );
40+
41+ $ fetch = $ result ->iterateAssociative ();
42+ assertType ('Traversable<int, array{email: string, adaid: int<-32768, 32767>}> ' , $ fetch );
43+
44+ $ fetch = $ result ->iterateColumn ();
45+ assertType ('Traversable<int, string> ' , $ fetch );
46+
47+ $ fetch = $ result ->iterateKeyValue ();
48+ assertType ('Traversable<string, int<-32768, 32767>> ' , $ fetch );
49+ }
50+
51+ public function unionQueriesResult (Connection $ conn )
52+ {
53+ $ queries = ['SELECT adaid FROM ada ' , 'SELECT email FROM ada ' ];
54+
55+ foreach ($ queries as $ query ) {
56+ $ result = $ conn ->query ($ query );
57+ assertType ('array{adaid: int<-32768, 32767>}|array{email: string}|false ' , $ result ->fetchAssociative ());
58+ }
59+ }
60+ }
0 commit comments