Skip to content

Commit 6c176dd

Browse files
committed
Fix PHPStan deprecation
1 parent 6aff6fe commit 6c176dd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Type/PhpOption/FromReturnReturnTypeExtension.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Resolve\PHPStan\Type\PhpOption;
66

7+
use PhpParser\Node\Arg;
78
use PhpParser\Node\Expr\StaticCall;
89
use PHPStan\Analyser\Scope;
910
use PHPStan\Reflection\MethodReflection;
@@ -46,11 +47,14 @@ public function getTypeFromStaticMethodCall(
4647
? TypeUtil::forShallowComparison($scope->getType($methodCall->getArgs()[2]->value))
4748
: new NullType();
4849

49-
$callbackReturnType = ParametersAcceptorSelector::selectSingle(
50-
$callbackType->getCallableParametersAcceptors($scope),
51-
)->getReturnType();
50+
$parametersAcceptors = $callbackType->getCallableParametersAcceptors($scope);
5251

53-
$valueType = TypeCombinator::remove($callbackReturnType, $noneValueType);
52+
$args = isset($methodCall->getArgs()[1])
53+
? [new Arg($methodCall->getArgs()[1]->value, unpack: true)]
54+
: [];
55+
56+
$returnType = ParametersAcceptorSelector::selectFromArgs($scope, $args, $parametersAcceptors)->getReturnType();
57+
$valueType = TypeCombinator::remove($returnType, $noneValueType);
5458

5559
return new GenericObjectType('PhpOption\LazyOption', [
5660
$valueType->generalize(GeneralizePrecision::templateArgument()),

0 commit comments

Comments
 (0)