Skip to content

Commit be0d061

Browse files
authored
Fix PHPStan deprecations (#683)
1 parent f869fe5 commit be0d061

5 files changed

+35
-7
lines changed

src/Extensions/MysqliEscapeStringDynamicReturnTypeExtension.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
5353
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
5454
{
5555
$args = $functionCall->getArgs();
56-
$defaultReturn = ParametersAcceptorSelector::selectSingle($functionReflection->getVariants())->getReturnType();
56+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
57+
$scope,
58+
$functionCall->getArgs(),
59+
$functionReflection->getVariants()
60+
)->getReturnType();
5761

5862
if (QueryReflection::getRuntimeConfiguration()->throwsMysqliExceptions($this->phpVersion)) {
5963
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));
@@ -71,7 +75,11 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
7175
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
7276
{
7377
$args = $methodCall->getArgs();
74-
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
78+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
79+
$scope,
80+
$methodCall->getArgs(),
81+
$methodReflection->getVariants()
82+
)->getReturnType();
7583

7684
if (QueryReflection::getRuntimeConfiguration()->throwsMysqliExceptions($this->phpVersion)) {
7785
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));

src/Extensions/MysqliQueryDynamicReturnTypeExtension.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public function isFunctionSupported(FunctionReflection $functionReflection): boo
5454
public function getTypeFromFunctionCall(FunctionReflection $functionReflection, FuncCall $functionCall, Scope $scope): Type
5555
{
5656
$args = $functionCall->getArgs();
57-
$defaultReturn = ParametersAcceptorSelector::selectSingle($functionReflection->getVariants())->getReturnType();
57+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
58+
$scope,
59+
$functionCall->getArgs(),
60+
$functionReflection->getVariants()
61+
)->getReturnType();
5862

5963
if (QueryReflection::getRuntimeConfiguration()->throwsMysqliExceptions($this->phpVersion)) {
6064
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));
@@ -79,7 +83,11 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
7983
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
8084
{
8185
$args = $methodCall->getArgs();
82-
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
86+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
87+
$scope,
88+
$methodCall->getArgs(),
89+
$methodReflection->getVariants()
90+
)->getReturnType();
8391

8492
if (QueryReflection::getRuntimeConfiguration()->throwsMysqliExceptions($this->phpVersion)) {
8593
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));

src/Extensions/PdoPrepareDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
4545
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4646
{
4747
$args = $methodCall->getArgs();
48-
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
48+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
49+
$scope,
50+
$methodCall->getArgs(),
51+
$methodReflection->getVariants()
52+
)->getReturnType();
4953

5054
if (QueryReflection::getRuntimeConfiguration()->throwsPdoExceptions($this->phpVersion)) {
5155
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));

src/Extensions/PdoQuoteDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
4747
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
4848
{
4949
$args = $methodCall->getArgs();
50-
$defaultReturn = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
50+
$defaultReturn = ParametersAcceptorSelector::selectFromArgs(
51+
$scope,
52+
$methodCall->getArgs(),
53+
$methodReflection->getVariants()
54+
)->getReturnType();
5155

5256
if (QueryReflection::getRuntimeConfiguration()->throwsPdoExceptions($this->phpVersion)) {
5357
$defaultReturn = TypeCombinator::remove($defaultReturn, new ConstantBooleanType(false));

src/Extensions/PdoStatementFetchDynamicReturnTypeExtension.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
5555

5656
public function getTypeFromMethodCall(MethodReflection $methodReflection, MethodCall $methodCall, Scope $scope): Type
5757
{
58-
$returnType = ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
58+
$returnType = ParametersAcceptorSelector::selectFromArgs(
59+
$scope,
60+
$methodCall->getArgs(),
61+
$methodReflection->getVariants()
62+
)->getReturnType();
5963

6064
try {
6165
$resultType = $this->inferType($methodReflection, $methodCall, $scope);

0 commit comments

Comments
 (0)