Skip to content

Commit

Permalink
Fix PHPStan deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
axlon committed Sep 28, 2024
1 parent 6aff6fe commit 6c176dd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Type/PhpOption/FromReturnReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Resolve\PHPStan\Type\PhpOption;

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

$callbackReturnType = ParametersAcceptorSelector::selectSingle(
$callbackType->getCallableParametersAcceptors($scope),
)->getReturnType();
$parametersAcceptors = $callbackType->getCallableParametersAcceptors($scope);

$valueType = TypeCombinator::remove($callbackReturnType, $noneValueType);
$args = isset($methodCall->getArgs()[1])
? [new Arg($methodCall->getArgs()[1]->value, unpack: true)]
: [];

$returnType = ParametersAcceptorSelector::selectFromArgs($scope, $args, $parametersAcceptors)->getReturnType();
$valueType = TypeCombinator::remove($returnType, $noneValueType);

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

0 comments on commit 6c176dd

Please sign in to comment.