Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions stubs/PDOStatement.stub
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ class PDOStatement implements Traversable, IteratorAggregate
* @return array{name: string, table?: string, native_type?: string, len: int, flags: array<int, string>, precision: int<0, max>, pdo_type: PDO::PARAM_* }|false
*/
public function getColumnMeta(int $column) {}

/**
* @return Iterator
*/
public function getIterator() {}
}
2 changes: 2 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ private static function findTestFiles(): iterable
yield __DIR__ . '/../Rules/Methods/data/bug-4801.php';
yield __DIR__ . '/../Rules/Arrays/data/narrow-superglobal.php';
yield __DIR__ . '/../Rules/Methods/data/bug-12927.php';

// note: files in ./nsrt will be automatically picked up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to add this.

This is a consequence of the first line

foreach (self::findTestDataFilesFromDirectory(__DIR__ . '/nsrt') as $testFile) {
			yield $testFile;
		}

}

/**
Expand Down
13 changes: 13 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-8886.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php // lint >= 8.0

namespace Bug8886;

use PDO;
use function PHPStan\Testing\assertType;

function testPDOStatementGetIterator(): void {
$pdo = new PDO('sqlite::memory:');
$stmt = $pdo->query('SELECT 1');

assertType('Iterator', $stmt->getIterator());
}
Loading