Skip to content

Commit 5f097a7

Browse files
committed
add more test coverage
1 parent a2114ec commit 5f097a7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

tests/PHPStan/Analyser/data/non-empty-string-file-functions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class Foo
1212
* @param numeric-string $numericString
1313
*/
1414
public function strTypes($nonES, $nonFalsyString, $numericString) {
15-
if (is_dir($nonES)) {
15+
if (dir($nonES)) {
16+
assertType('non-empty-string', $nonES);
17+
} else {
1618
assertType('non-empty-string', $nonES);
1719
}
1820
assertType('non-empty-string', $nonES);
@@ -32,6 +34,8 @@ public function fileNonEmptyStrings(string $s): void
3234
{
3335
if (dir($s)) {
3436
assertType('non-empty-string', $s);
37+
} else {
38+
assertType('string', $s);
3539
}
3640
assertType('string', $s);
3741

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,4 +1094,11 @@ public function testBug10502(): void
10941094
]);
10951095
}
10961096

1097+
public function testBug6788(): void
1098+
{
1099+
$this->checkAlwaysTrueCheckTypeFunctionCall = true;
1100+
$this->treatPhpDocTypesAsCertain = true;
1101+
$this->analyse([__DIR__ . '/data/bug-6788.php'], []);
1102+
}
1103+
10971104
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Bug6788;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @param non-empty-string $nonES
9+
* @param non-falsy-string $nonFalsyString
10+
* @param numeric-string $numericString
11+
*/
12+
function strTypes($nonES, $nonFalsyString, $numericString) {
13+
if (chdir($nonES)) {
14+
}
15+
if (chdir($nonFalsyString)) {
16+
}
17+
if (chdir($numericString)) {
18+
}
19+
}

0 commit comments

Comments
 (0)