Skip to content

Commit b031f5c

Browse files
committed
fixes #8886
1 parent 83f1509 commit b031f5c

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ private static function findTestFiles(): iterable
229229
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php';
230230
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php';
231231
yield __DIR__ . '/../Rules/Methods/data/bug-12927.php';
232+
yield __DIR__ . '/nsrt/bug-8886.php';
232233
}
233234

234235
/**
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)