Skip to content

Commit 3bf98fb

Browse files
phpstan-botclaude
andcommitted
Test dynamic first-class callable nullsafe method call
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6564c7b commit 3bf98fb

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

tests/PHPStan/Rules/Methods/NullsafeMethodCallOnFirstClassCallableRuleTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public function testRule(): void
2727
],
2828
[
2929
'Cannot combine nullsafe operator with Closure creation.',
30-
28,
30+
26,
31+
],
32+
[
33+
'Cannot combine nullsafe operator with Closure creation.',
34+
34,
3135
],
3236
]);
3337
}

tests/PHPStan/Rules/Methods/data/nullsafe-first-class-callable.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ function test(?Foo $foo): void
2020
$foo?->doFoo(...);
2121
}
2222

23+
function testDynamic(?Foo $foo, string $method): void
24+
{
25+
// dynamic method name - also a fatal error in PHP
26+
$foo?->{$method}(...);
27+
}
28+
2329

2430
class HelloWorld
2531
{

0 commit comments

Comments
 (0)