Skip to content

Commit 6184790

Browse files
committed
added regression test
1 parent 5d82141 commit 6184790

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/Type/Php/SprintfFunctionDynamicReturnTypeExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpParser\Node\Expr\FuncCall;
88
use PHPStan\Analyser\Scope;
99
use PHPStan\Internal\CombinationsHelper;
10-
use PHPStan\Php\PhpVersion;
1110
use PHPStan\Reflection\FunctionReflection;
1211
use PHPStan\Reflection\InitializerExprTypeResolver;
1312
use PHPStan\TrinaryLogic;

tests/PHPStan/Rules/Comparison/StrictComparisonOfDifferentTypesRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,4 +1052,10 @@ public function testBug10697(): void
10521052
$this->analyse([__DIR__ . '/data/bug-10697.php'], []);
10531053
}
10541054

1055+
public function testBug10493(): void
1056+
{
1057+
$this->checkAlwaysTrueStrictComparison = true;
1058+
$this->analyse([__DIR__ . '/data/bug-10493.php'], []);
1059+
}
1060+
10551061
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php // lint >= 8.1
2+
3+
namespace Bug10493;
4+
5+
class Foo
6+
{
7+
public function __construct(
8+
private readonly ?string $old,
9+
private readonly ?string $new,
10+
)
11+
{
12+
}
13+
14+
public function foo(): ?string
15+
{
16+
$return = sprintf('%s%s', $this->old, $this->new);
17+
18+
if ($return === '') {
19+
return null;
20+
}
21+
22+
return $return;
23+
}
24+
}

0 commit comments

Comments
 (0)