Skip to content

Commit

Permalink
Fixes after PHPStan updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 26, 2024
1 parent a110d8a commit c17a736
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool

public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
{
$defaultReturnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
$defaultReturnType = ParametersAcceptorSelector::selectFromArgs(
$scope,
$methodCall->getArgs(),
$methodReflection->getVariants()
)->getReturnType();

$queryBuilderType = new ObjectType(QueryBuilder::class);
$var = $methodCall->var;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Doctrine\Driver\DriverDetector;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Doctrine\ObjectMetadataResolver;
use PHPStan\Type\DynamicMethodReturnTypeExtension;
Expand Down Expand Up @@ -76,7 +75,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
}

$rowCountMethod = $resultReflection->getNativeMethod('rowCount');
$variant = ParametersAcceptorSelector::selectSingle($rowCountMethod->getVariants());
$variant = $rowCountMethod->getOnlyVariant();

return $variant->getReturnType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public function getTypeFromMethodCall(
if (isset($args[$argIndex])) {
$hydrationMode = $scope->getType($args[$argIndex]->value);
} else {
$parametersAcceptor = ParametersAcceptorSelector::selectSingle(
$methodReflection->getVariants(),
$parametersAcceptor = ParametersAcceptorSelector::selectFromArgs(
$scope,
$methodCall->getArgs(),
$methodReflection->getVariants()
);
$parameter = $parametersAcceptor->getParameters()[$argIndex];
$hydrationMode = $parameter->getDefaultValue() ?? new NullType();
Expand Down
2 changes: 1 addition & 1 deletion src/Type/Doctrine/Query/QueryResultTypeWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public function walkFunction($function): string
if ($this->driverType === DriverDetector::MYSQLI || $this->driverType === DriverDetector::PDO_MYSQL || $this->driverType === DriverDetector::SQLITE3 || $this->driverType === DriverDetector::PDO_SQLITE) {
$type = new FloatType();

$cannotBeNegative = $exprType->isSmallerThan(new ConstantIntegerType(0))->no();
$cannotBeNegative = $exprType->isSmallerThan(new ConstantIntegerType(0), $this->phpVersion)->no();
$canBeNegative = !$cannotBeNegative;
if ($canBeNegative) {
$type = TypeCombinator::addNull($type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node\Identifier;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\Doctrine\DoctrineTypeUtils;
use PHPStan\Type\DynamicMethodReturnTypeExtension;
use PHPStan\Type\MixedType;
Expand Down Expand Up @@ -39,9 +38,7 @@ public function getClass(): string

public function isMethodSupported(MethodReflection $methodReflection): bool
{
$returnType = ParametersAcceptorSelector::selectSingle(
$methodReflection->getVariants(),
)->getReturnType();
$returnType = $methodReflection->getVariants()[0]->getReturnType();
if ($returnType instanceof MixedType) {
return false;
}
Expand Down

0 comments on commit c17a736

Please sign in to comment.