Skip to content

Commit 3d08c56

Browse files
phpstan-botclaude
andcommitted
Use real classes with native intersection return types instead of inline @var
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eb8304a commit 3d08c56

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

tests/PHPStan/Analyser/nsrt/bug-14362.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,25 @@ interface F
4646

4747
}
4848

49+
class G {
50+
public static function u(): A&E {
51+
throw new \Exception();
52+
}
53+
}
54+
55+
class H {
56+
public static function u(): B&F {
57+
throw new \Exception();
58+
}
59+
}
60+
4961
function () : void {
5062
assertType('Closure(Bug14362\B): int', C::u()(...));
5163
assertType('Closure(Bug14362\B): int', D::u()(...));
5264

5365
// Intersection with only yes-callable types (both have __invoke)
54-
/** @var A&E $yesCallable */
55-
$yesCallable = C::u();
56-
assertType('(Closure(Bug14362\B): int)|(Closure(string): bool)', $yesCallable(...));
66+
assertType('(Closure(Bug14362\B): int)|(Closure(string): bool)', G::u()(...));
5767

5868
// Intersection with only maybe-callable types (neither has __invoke)
59-
/** @var B&F $maybeCallable */
60-
$maybeCallable = C::u();
61-
assertType('Closure', $maybeCallable(...));
69+
assertType('Closure', H::u()(...));
6270
};

0 commit comments

Comments
 (0)