Skip to content

Commit 81ad9b8

Browse files
committed
Added regression test
1 parent f9aea85 commit 81ad9b8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,4 +1038,10 @@ public function testBug6788(): void
10381038
$this->analyse([__DIR__ . '/data/bug-6788.php'], []);
10391039
}
10401040

1041+
public function testBug13268(): void
1042+
{
1043+
$this->treatPhpDocTypesAsCertain = true;
1044+
$this->analyse([__DIR__ . '/data/bug-13268.php'], []);
1045+
}
1046+
10411047
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug13268;
4+
5+
class HelloWorld
6+
{
7+
public function assignInCall(string $string): ?string
8+
{
9+
if (
10+
is_string(
11+
$string = realpath($string)
12+
)
13+
) {
14+
throw new \RuntimeException('Refusing to overwrite existing file: ' . $string);
15+
}
16+
return null;
17+
}
18+
19+
public function dumpToLog(mixed $dumpToLog): ?string
20+
{
21+
if (is_string($dumpToLog)) {
22+
if (file_exists($dumpToLog) || is_string($dumpToLog = realpath($dumpToLog))) {
23+
throw new \RuntimeException('Refusing to overwrite existing file: ' . $dumpToLog);
24+
}
25+
}
26+
return null;
27+
}
28+
}

0 commit comments

Comments
 (0)