Skip to content

Commit e86594d

Browse files
FetchAll actually returns list of results, not an array per se. (#638)
Co-authored-by: Markus Staab <[email protected]> Co-authored-by: Markus Staab <[email protected]>
1 parent 4262a41 commit e86594d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Expr\MethodCall;
99
use PHPStan\Analyser\Scope;
1010
use PHPStan\Reflection\MethodReflection;
11+
use PHPStan\Type\Accessory\AccessoryArrayListType;
1112
use PHPStan\Type\ArrayType;
1213
use PHPStan\Type\Constant\ConstantArrayType;
1314
use PHPStan\Type\DynamicMethodReturnTypeExtension;
@@ -113,7 +114,7 @@ private function reduceResultType(MethodReflection $methodReflection, Type $resu
113114
if ('fetch' === $methodName) {
114115
return TypeCombinator::addNull($resultType);
115116
} elseif ('fetchAll' === $methodName) {
116-
return new ArrayType(new IntegerType(), $resultType);
117+
return AccessoryArrayListType::intersectWith(new ArrayType(new IntegerType(), $resultType));
117118
} elseif ('fetchPairs' === $methodName && $resultType instanceof ConstantArrayType && 2 === \count($resultType->getValueTypes())) {
118119
return new ArrayType($resultType->getValueTypes()[0], $resultType->getValueTypes()[1]);
119120
} elseif ('fetchSingle' === $methodName && $resultType instanceof ConstantArrayType && 1 === \count($resultType->getValueTypes())) {

0 commit comments

Comments
 (0)