Skip to content

Commit 24e0653

Browse files
phpstan-botclaude
authored andcommitted
Add non-regression test for dynamic static call with by-reference parameter
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent dea8766 commit 24e0653

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,10 @@ public function testBug6822(): void
237237
$this->analyse([__DIR__ . '/../../Analyser/nsrt/bug-6822.php'], []);
238238
}
239239

240+
public function testBug5020(): void
241+
{
242+
$this->treatPhpDocTypesAsCertain = true;
243+
$this->analyse([__DIR__ . '/data/bug-5020.php'], []);
244+
}
245+
240246
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Bug5020;
4+
5+
interface ITransformer
6+
{
7+
public static function Transform(string $theInput, bool &$theErrorEncountered): string;
8+
}
9+
10+
class Transformer implements ITransformer
11+
{
12+
public static function Transform(string $theInput, bool &$theErrorEncountered): string
13+
{
14+
if ($theInput === 'invalid') {
15+
$theErrorEncountered = true;
16+
return '';
17+
}
18+
return strtoupper(trim($theInput));
19+
}
20+
}
21+
22+
/**
23+
* @param class-string<Transformer> $transformer
24+
*/
25+
function foo(string $transformer): void
26+
{
27+
$input = ' asdasda asdasd ';
28+
$error = false;
29+
$output = $transformer::Transform($input, $error);
30+
if ($error) {
31+
32+
}
33+
}

0 commit comments

Comments
 (0)