|
124 | 124 | use PHPStan\Reflection\MethodReflection;
|
125 | 125 | use PHPStan\Reflection\Native\NativeMethodReflection;
|
126 | 126 | use PHPStan\Reflection\Native\NativeParameterReflection;
|
| 127 | +use PHPStan\Reflection\ParameterReflection; |
127 | 128 | use PHPStan\Reflection\ParameterReflectionWithPhpDocs;
|
128 | 129 | use PHPStan\Reflection\ParametersAcceptor;
|
129 | 130 | use PHPStan\Reflection\ParametersAcceptorSelector;
|
@@ -3457,8 +3458,39 @@ private function processClosureNode(
|
3457 | 3458 | }
|
3458 | 3459 |
|
3459 | 3460 | $acceptors = $passedToType->getCallableParametersAcceptors($scope);
|
3460 |
| - if (count($acceptors) === 1) { |
3461 |
| - $callableParameters = $acceptors[0]->getParameters(); |
| 3461 | + if (count($acceptors) > 0) { |
| 3462 | + foreach ($acceptors as $acceptor) { |
| 3463 | + if ($callableParameters === null) { |
| 3464 | + $callableParameters = array_map(static fn (ParameterReflection $callableParameter) => new NativeParameterReflection( |
| 3465 | + $callableParameter->getName(), |
| 3466 | + $callableParameter->isOptional(), |
| 3467 | + $callableParameter->getType(), |
| 3468 | + $callableParameter->passedByReference(), |
| 3469 | + $callableParameter->isVariadic(), |
| 3470 | + $callableParameter->getDefaultValue(), |
| 3471 | + ), $acceptor->getParameters()); |
| 3472 | + continue; |
| 3473 | + } |
| 3474 | + |
| 3475 | + $newParameters = []; |
| 3476 | + foreach ($acceptor->getParameters() as $i => $callableParameter) { |
| 3477 | + if (!array_key_exists($i, $callableParameters)) { |
| 3478 | + $newParameters[] = $callableParameter; |
| 3479 | + continue; |
| 3480 | + } |
| 3481 | + |
| 3482 | + $newParameters[] = $callableParameters[$i]->union(new NativeParameterReflection( |
| 3483 | + $callableParameter->getName(), |
| 3484 | + $callableParameter->isOptional(), |
| 3485 | + $callableParameter->getType(), |
| 3486 | + $callableParameter->passedByReference(), |
| 3487 | + $callableParameter->isVariadic(), |
| 3488 | + $callableParameter->getDefaultValue(), |
| 3489 | + )); |
| 3490 | + } |
| 3491 | + |
| 3492 | + $callableParameters = $newParameters; |
| 3493 | + } |
3462 | 3494 | }
|
3463 | 3495 | }
|
3464 | 3496 |
|
@@ -3639,8 +3671,39 @@ private function processArrowFunctionNode(
|
3639 | 3671 | }
|
3640 | 3672 |
|
3641 | 3673 | $acceptors = $passedToType->getCallableParametersAcceptors($scope);
|
3642 |
| - if (count($acceptors) === 1) { |
3643 |
| - $callableParameters = $acceptors[0]->getParameters(); |
| 3674 | + if (count($acceptors) > 0) { |
| 3675 | + foreach ($acceptors as $acceptor) { |
| 3676 | + if ($callableParameters === null) { |
| 3677 | + $callableParameters = array_map(static fn (ParameterReflection $callableParameter) => new NativeParameterReflection( |
| 3678 | + $callableParameter->getName(), |
| 3679 | + $callableParameter->isOptional(), |
| 3680 | + $callableParameter->getType(), |
| 3681 | + $callableParameter->passedByReference(), |
| 3682 | + $callableParameter->isVariadic(), |
| 3683 | + $callableParameter->getDefaultValue(), |
| 3684 | + ), $acceptor->getParameters()); |
| 3685 | + continue; |
| 3686 | + } |
| 3687 | + |
| 3688 | + $newParameters = []; |
| 3689 | + foreach ($acceptor->getParameters() as $i => $callableParameter) { |
| 3690 | + if (!array_key_exists($i, $callableParameters)) { |
| 3691 | + $newParameters[] = $callableParameter; |
| 3692 | + continue; |
| 3693 | + } |
| 3694 | + |
| 3695 | + $newParameters[] = $callableParameters[$i]->union(new NativeParameterReflection( |
| 3696 | + $callableParameter->getName(), |
| 3697 | + $callableParameter->isOptional(), |
| 3698 | + $callableParameter->getType(), |
| 3699 | + $callableParameter->passedByReference(), |
| 3700 | + $callableParameter->isVariadic(), |
| 3701 | + $callableParameter->getDefaultValue(), |
| 3702 | + )); |
| 3703 | + } |
| 3704 | + |
| 3705 | + $callableParameters = $newParameters; |
| 3706 | + } |
3644 | 3707 | }
|
3645 | 3708 | }
|
3646 | 3709 |
|
|
0 commit comments