Skip to content

Commit 6ec218e

Browse files
committed
fix
1 parent 4f15453 commit 6ec218e

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ parameters:
2323
count: 2
2424
path: src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php
2525

26-
-
27-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantArrayType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantArrays\\(\\) instead\\.$#"
28-
count: 1
29-
path: src/Extensions/DoctrineResultDynamicReturnTypeExtension.php
30-
31-
-
32-
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantArrayType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantArrays\\(\\) instead\\.$#"
33-
count: 1
34-
path: src/Extensions/PdoStatementColumnCountDynamicReturnTypeExtension.php
35-
3626
-
3727
message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantStringType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantStrings\\(\\) instead\\.$#"
3828
count: 1

src/Extensions/DoctrineResultDynamicReturnTypeExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ private function inferType(MethodReflection $methodReflection, MethodCall $metho
6767
$resultType = $scope->getType($methodCall->var);
6868
if ('columncount' === strtolower($methodReflection->getName())) {
6969
if ($resultType instanceof DoctrineResultObjectType) {
70-
$resultRowType = $resultType->getRowType();
70+
$arrays = $resultType->getRowType()->getConstantArrays();
71+
if (count($arrays) === 1) {
72+
$resultRowType = $arrays[0];
7173

72-
if ($resultRowType instanceof ConstantArrayType) {
7374
$columnCount = \count($resultRowType->getKeyTypes()) / 2;
7475
if (! \is_int($columnCount)) {
7576
throw new ShouldNotHappenException();

src/Extensions/PdoStatementColumnCountDynamicReturnTypeExtension.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
3232
$statementType = $scope->getType($methodCall->var);
3333

3434
if ($statementType instanceof PdoStatementObjectType) {
35-
$rowType = $statementType->newWithFetchType(QueryReflector::FETCH_TYPE_NUMERIC)->getRowType();
36-
if ($rowType instanceof ConstantArrayType) {
35+
$arrays = $statementType->newWithFetchType(QueryReflector::FETCH_TYPE_NUMERIC)->getRowType()->getConstantArrays();
36+
if (count($arrays) === 1) {
37+
$rowType = $arrays[0];
3738
return new ConstantIntegerType(\count($rowType->getKeyTypes()));
3839
}
3940
}

0 commit comments

Comments
 (0)