Skip to content

Commit a40cea7

Browse files
committed
fixes #8886
1 parent f615b1a commit a40cea7

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

stubs/PDOStatement.stub

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ class PDOStatement implements Traversable, IteratorAggregate
1919
* @return array{name: string, table?: string, native_type?: string, len: int, flags: array<int, string>, precision: int<0, max>, pdo_type: PDO::PARAM_* }|false
2020
*/
2121
public function getColumnMeta(int $column) {}
22+
23+
/**
24+
* @return Iterator
25+
*/
26+
public function getIterator() {}
2227
}

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ private static function findTestFiles(): iterable
211211
yield __DIR__ . '/../Rules/Arrays/data/bug-11679.php';
212212
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php';
213213
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php';
214+
215+
yield __DIR__ . '/nsrt/bug-8886.php';
214216
}
215217

216218
/**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Bug8886;
4+
5+
use PDO;
6+
use function PHPStan\Testing\assertType;
7+
8+
function testPDOStatementGetIterator(): void {
9+
$pdo = new PDO('sqlite::memory:');
10+
$stmt = $pdo->query('SELECT 1');
11+
assertType('Iterator', $stmt->getIterator());
12+
}

0 commit comments

Comments
 (0)