|
10 | 10 | use PHPStan\Reflection\ExtendedMethodReflection; |
11 | 11 | use PHPStan\Reflection\ExtendedParametersAcceptor; |
12 | 12 | use PHPStan\Reflection\MethodReflection; |
13 | | -use PHPStan\Reflection\ParametersAcceptor; |
14 | 13 | use PHPStan\ShouldNotHappenException; |
15 | 14 | use PHPStan\TrinaryLogic; |
16 | 15 | use PHPStan\Type\Type; |
@@ -80,10 +79,22 @@ public function getPrototype(): ClassMemberReflection |
80 | 79 |
|
81 | 80 | public function getVariants(): array |
82 | 81 | { |
83 | | - $returnType = TypeCombinator::intersect(...array_map(static fn (MethodReflection $method): Type => TypeCombinator::intersect(...array_map(static fn (ParametersAcceptor $acceptor): Type => $acceptor->getReturnType(), $method->getVariants())), $this->methods)); |
84 | | - $phpDocReturnType = TypeCombinator::intersect(...array_map(static fn (MethodReflection $method): Type => TypeCombinator::intersect(...array_map(static fn (ParametersAcceptor $acceptor): Type => $acceptor->getPhpDocReturnType(), $method->getVariants())), $this->methods)); |
85 | | - $nativeReturnType = TypeCombinator::intersect(...array_map(static fn (MethodReflection $method): Type => TypeCombinator::intersect(...array_map(static fn (ParametersAcceptor $acceptor): Type => $acceptor->getNativeReturnType(), $method->getVariants())), $this->methods)); |
| 82 | + $returnTypes = []; |
| 83 | + $phpDocReturnTypes = []; |
| 84 | + $nativeReturnTypes = []; |
| 85 | + foreach ($this->methods as $method) { |
| 86 | + $variants = $method->getVariants(); |
| 87 | + |
| 88 | + foreach ($variants as $acceptor) { |
| 89 | + $returnTypes[] = $acceptor->getReturnType(); |
| 90 | + $phpDocReturnTypes[] = $acceptor->getPhpDocReturnType(); |
| 91 | + $nativeReturnTypes[] = $acceptor->getNativeReturnType(); |
| 92 | + } |
| 93 | + } |
86 | 94 |
|
| 95 | + $returnType = TypeCombinator::intersect(...$returnTypes); |
| 96 | + $phpDocReturnType = TypeCombinator::intersect(...$phpDocReturnTypes); |
| 97 | + $nativeReturnType = TypeCombinator::intersect(...$nativeReturnTypes); |
87 | 98 | return array_map(static fn (ExtendedParametersAcceptor $acceptor): ExtendedParametersAcceptor => new ExtendedFunctionVariant( |
88 | 99 | $acceptor->getTemplateTypeMap(), |
89 | 100 | $acceptor->getResolvedTemplateTypeMap(), |
|
0 commit comments