Skip to content

Commit f529971

Browse files
Another strategy
1 parent c703aa0 commit f529971

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

.claude/worktrees/agent-a624340d

Lines changed: 0 additions & 1 deletion
This file was deleted.

.claude/worktrees/agent-af2804bc

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/PhpDoc/TypeNodeResolver.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
use PHPStan\Type\IterableType;
8787
use PHPStan\Type\KeyOfType;
8888
use PHPStan\Type\MixedType;
89-
use PHPStan\Type\NeverType;
9089
use PHPStan\Type\NewObjectType;
9190
use PHPStan\Type\NonAcceptingNeverType;
9291
use PHPStan\Type\NonexistentParentClassType;
@@ -936,23 +935,17 @@ static function (string $variance): TemplateTypeVariance {
936935

937936
try {
938937
if (count($genericTypes) === 1) { // Foo<ValueType>
939-
$iterableType = new IterableType(new MixedType(true), $genericTypes[0]);
940-
$result = TypeCombinator::intersect($mainType, $iterableType);
941-
if (!$result instanceof NeverType) {
942-
return $result;
943-
}
944-
945-
return new IntersectionType([$mainType, $iterableType]);
938+
return TypeCombinator::intersect(
939+
$mainType,
940+
new IterableType(new MixedType(true), $genericTypes[0]),
941+
);
946942
}
947943

948944
if (count($genericTypes) === 2) { // Foo<KeyType, ValueType>
949-
$iterableType = new IterableType($genericTypes[0], $genericTypes[1]);
950-
$result = TypeCombinator::intersect($mainType, $iterableType);
951-
if (!$result instanceof NeverType) {
952-
return $result;
953-
}
954-
955-
return new IntersectionType([$mainType, $iterableType]);
945+
return TypeCombinator::intersect(
946+
$mainType,
947+
new IterableType($genericTypes[0], $genericTypes[1]),
948+
);
956949
}
957950
} finally {
958951
if ($mainTypeClassName !== null) {

stubs/PDOStatement.stub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

33
/**
4-
* @implements Traversable<array<int|string, mixed>>
5-
* @implements IteratorAggregate<array<int|string, mixed>>
4+
* @implements Traversable<mixed>
5+
* @implements IteratorAggregate<mixed>
66
* @link https://php.net/manual/en/class.pdostatement.php
77
*/
88
class PDOStatement implements Traversable, IteratorAggregate
@@ -21,7 +21,7 @@ class PDOStatement implements Traversable, IteratorAggregate
2121
public function getColumnMeta(int $column) {}
2222

2323
/**
24-
* @return Iterator<mixed, array<int|string, mixed>>
24+
* @return Iterator<mixed, mixed>
2525
*/
2626
public function getIterator() {}
2727
}

0 commit comments

Comments
 (0)