Skip to content

Commit f63df3b

Browse files
committed
add test for bug 10396
1 parent 022a1e1 commit f63df3b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,15 @@ public function testParameterClosureTypeExtension(): void
17801780
]);
17811781
}
17821782

1783+
public function testBug10396(): void
1784+
{
1785+
if (PHP_VERSION_ID < 70400) {
1786+
$this->markTestSkipped('Test requires PHP 7.4');
1787+
}
1788+
1789+
$this->analyse([__DIR__ . '/data/bug-10396.php'], []);
1790+
}
1791+
17831792
public function testBug11559(): void
17841793
{
17851794
$this->analyse([__DIR__ . '/data/bug-11559.php'], []);

Diff for: tests/PHPStan/Rules/Functions/data/bug-10396.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types = 1); // lint >= 8.1
2+
3+
namespace Bug10396;
4+
5+
function test(): string|null {
6+
$flags = \PREG_OFFSET_CAPTURE | \PREG_UNMATCHED_AS_NULL;
7+
return preg_replace_callback('/bar/', callback(...), 'foobar', -1, $count, $flags);
8+
}
9+
10+
/**
11+
* @param array<int|string, array{0: string|null, 1: int}> $match
12+
* @return string
13+
*/
14+
function callback(array $match): string {
15+
return (string) $match[0][1];
16+
}

0 commit comments

Comments
 (0)