Skip to content

Commit 04f8a96

Browse files
phpstan-botclaude
andcommitted
Fix impossible A&E intersection type in test
A&E was impossible since both had __invoke with incompatible signatures. Replace with realistic test cases: A&B&E (one callable + maybe-callable types) and B&E (only maybe-callable types). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3d08c56 commit 04f8a96

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,33 @@ public function __invoke(B $b): int {
3737
}
3838

3939
interface E
40-
{
41-
public function __invoke(string $s): bool;
42-
}
43-
44-
interface F
4540
{
4641

4742
}
4843

4944
class G {
50-
public static function u(): A&E {
51-
throw new \Exception();
45+
public static function u(): A&B&E {
46+
return new class() implements A, B, E {
47+
public function __invoke(B $b): int {
48+
return 1;
49+
}
50+
};
5251
}
5352
}
5453

5554
class H {
56-
public static function u(): B&F {
57-
throw new \Exception();
55+
public static function u(): B&E {
56+
return new class() implements B, E {
57+
};
5858
}
5959
}
6060

6161
function () : void {
6262
assertType('Closure(Bug14362\B): int', C::u()(...));
6363
assertType('Closure(Bug14362\B): int', D::u()(...));
6464

65-
// Intersection with only yes-callable types (both have __invoke)
66-
assertType('(Closure(Bug14362\B): int)|(Closure(string): bool)', G::u()(...));
65+
// Intersection with one yes-callable and multiple maybe-callable types
66+
assertType('Closure(Bug14362\B): int', G::u()(...));
6767

6868
// Intersection with only maybe-callable types (neither has __invoke)
6969
assertType('Closure', H::u()(...));

0 commit comments

Comments
 (0)