Skip to content

Commit eb8304a

Browse files
phpstan-botclaude
andcommitted
Add tests for only-callable and only-maybe-callable intersection types
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 430589e commit eb8304a

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,27 @@ public function __invoke(B $b): int {
3636
}
3737
}
3838

39+
interface E
40+
{
41+
public function __invoke(string $s): bool;
42+
}
43+
44+
interface F
45+
{
46+
47+
}
48+
3949
function () : void {
4050
assertType('Closure(Bug14362\B): int', C::u()(...));
4151
assertType('Closure(Bug14362\B): int', D::u()(...));
52+
53+
// 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(...));
57+
58+
// Intersection with only maybe-callable types (neither has __invoke)
59+
/** @var B&F $maybeCallable */
60+
$maybeCallable = C::u();
61+
assertType('Closure', $maybeCallable(...));
4262
};

0 commit comments

Comments
 (0)