Skip to content

Commit c17a736

Browse files
committed
Fixes after PHPStan updates
1 parent a110d8a commit c17a736

5 files changed

+12
-10
lines changed

Diff for: src/Type/Doctrine/DBAL/QueryBuilder/QueryBuilderExecuteMethodExtension.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3838

3939
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4040
{
41-
$defaultReturnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
41+
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs(
42+
$scope,
43+
$methodCall->getArgs(),
44+
$methodReflection->getVariants()
45+
)->getReturnType();
4246

4347
$queryBuilderType = new ObjectType(QueryBuilder::class);
4448
$var = $methodCall->var;

Diff for: src/Type/Doctrine/DBAL/RowCountMethodDynamicReturnTypeExtension.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Doctrine\Driver\DriverDetector;
1010
use PHPStan\Reflection\MethodReflection;
11-
use PHPStan\Reflection\ParametersAcceptorSelector;
1211
use PHPStan\Reflection\ReflectionProvider;
1312
use PHPStan\Type\Doctrine\ObjectMetadataResolver;
1413
use PHPStan\Type\DynamicMethodReturnTypeExtension;
@@ -76,7 +75,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
7675
}
7776

7877
$rowCountMethod = $resultReflection->getNativeMethod('rowCount');
79-
$variant = ParametersAcceptorSelector::selectSingle($rowCountMethod->getVariants());
78+
$variant = $rowCountMethod->getOnlyVariant();
8079

8180
return $variant->getReturnType();
8281
}

Diff for: src/Type/Doctrine/Query/QueryResultDynamicReturnTypeExtension.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ public function getTypeFromMethodCall(
6868
if (isset($args[$argIndex])) {
6969
$hydrationMode = $scope->getType($args[$argIndex]->value);
7070
} else {
71-
$parametersAcceptor = ParametersAcceptorSelector::selectSingle(
72-
$methodReflection->getVariants(),
71+
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
72+
$scope,
73+
$methodCall->getArgs(),
74+
$methodReflection->getVariants()
7375
);
7476
$parameter = $parametersAcceptor->getParameters()[$argIndex];
7577
$hydrationMode = $parameter->getDefaultValue() ?? new NullType();

Diff for: src/Type/Doctrine/Query/QueryResultTypeWalker.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ public function walkFunction($function): string
609609
if ($this->driverType === DriverDetector::MYSQLI || $this->driverType === DriverDetector::PDO_MYSQL || $this->driverType === DriverDetector::SQLITE3 || $this->driverType === DriverDetector::PDO_SQLITE) {
610610
$type = new FloatType();
611611

612-
$cannotBeNegative = $exprType->isSmallerThan(new ConstantIntegerType(0))->no();
612+
$cannotBeNegative = $exprType->isSmallerThan(new ConstantIntegerType(0), $this->phpVersion)->no();
613613
$canBeNegative = !$cannotBeNegative;
614614
if ($canBeNegative) {
615615
$type = TypeCombinator::addNull($type);

Diff for: src/Type/Doctrine/QueryBuilder/QueryBuilderMethodDynamicReturnTypeExtension.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpParser\Node\Identifier;
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Reflection\MethodReflection;
10-
use PHPStan\Reflection\ParametersAcceptorSelector;
1110
use PHPStan\Type\Doctrine\DoctrineTypeUtils;
1211
use PHPStan\Type\DynamicMethodReturnTypeExtension;
1312
use PHPStan\Type\MixedType;
@@ -39,9 +38,7 @@ public function getClass(): string
3938

4039
public function isMethodSupported(MethodReflection $methodReflection): bool
4140
{
42-
$returnType = ParametersAcceptorSelector::selectSingle(
43-
$methodReflection->getVariants(),
44-
)->getReturnType();
41+
$returnType = $methodReflection->getVariants()[0]->getReturnType();
4542
if ($returnType instanceof MixedType) {
4643
return false;
4744
}

0 commit comments

Comments
 (0)