Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions stubs/PDOStatement.stub
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* @implements Traversable<array<int|string, mixed>>
* @implements IteratorAggregate<array<int|string, mixed>>
* @implements Traversable<mixed>
* @implements IteratorAggregate<mixed>
* @link https://php.net/manual/en/class.pdostatement.php
*/
class PDOStatement implements Traversable, IteratorAggregate
Expand All @@ -21,7 +21,7 @@ class PDOStatement implements Traversable, IteratorAggregate
public function getColumnMeta(int $column) {}

/**
* @return Iterator<mixed, array<int|string, mixed>>
* @return Iterator<mixed, mixed>
*/
public function getIterator() {}
}
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/nsrt/bug-8886.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ function testPDOStatementGetIterator(): void {
$pdo = new PDO('sqlite::memory:');
$stmt = $pdo->query('SELECT 1');

assertType('Iterator<mixed, array<int|string, mixed>>', $stmt->getIterator());
assertType('Iterator<mixed, mixed>', $stmt->getIterator());
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public function testBug6348(): void
$this->analyse([__DIR__ . '/data/bug-6348.php'], []);
}

public function testBug14206(): void
{
$this->analyse([__DIR__ . '/data/bug-14206.php'], []);
}

public function testBug9055(): void
{
$this->analyse([__DIR__ . '/data/bug-9055.php'], [
Expand Down
17 changes: 17 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/bug-14206.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php declare(strict_types = 1);

namespace Bug14206;

use PDO;
use PDOStatement;

class Test
{
public function test(PDO $db): void
{
/** @var PDOStatement<int,string> */
$statement = $db->prepare('SELECT foo FROM bar');
$statement->setFetchMode(PDO::FETCH_COLUMN, 0);
$statement->execute();
}
}
Loading