Skip to content

Commit a7b7708

Browse files
committed
Added regression test
1 parent 6689c09 commit a7b7708

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,4 +1032,10 @@ public function testBug13291(): void
10321032
$this->analyse([__DIR__ . '/data/bug-13291.php'], []);
10331033
}
10341034

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

0 commit comments

Comments
 (0)