Skip to content

Commit 5dac347

Browse files
authored
Merge branch refs/heads/2.1.x into 2.2.x
2 parents 5a5255e + 789250e commit 5dac347

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Reflection/Type/IntersectionTypeMethodReflection.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PHPStan\Reflection\ExtendedMethodReflection;
1111
use PHPStan\Reflection\ExtendedParametersAcceptor;
1212
use PHPStan\Reflection\MethodReflection;
13-
use PHPStan\Reflection\ParametersAcceptor;
1413
use PHPStan\ShouldNotHappenException;
1514
use PHPStan\TrinaryLogic;
1615
use PHPStan\Type\Type;
@@ -80,10 +79,22 @@ public function getPrototype(): ClassMemberReflection
8079

8180
public function getVariants(): array
8281
{
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+
}
8694

95+
$returnType = TypeCombinator::intersect(...$returnTypes);
96+
$phpDocReturnType = TypeCombinator::intersect(...$phpDocReturnTypes);
97+
$nativeReturnType = TypeCombinator::intersect(...$nativeReturnTypes);
8798
return array_map(static fn (ExtendedParametersAcceptor $acceptor): ExtendedParametersAcceptor => new ExtendedFunctionVariant(
8899
$acceptor->getTemplateTypeMap(),
89100
$acceptor->getResolvedTemplateTypeMap(),

0 commit comments

Comments
 (0)