Skip to content

Commit 0364387

Browse files
devbananaondrejmirtes
authored andcommitted
Add unit tests
1 parent 16715c1 commit 0364387

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/PHPStan/Analyser/NodeScopeResolverTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ public function dataFileAsserts(): iterable
475475
yield from $this->gatherAssertTypes(__DIR__ . '/data/modulo-operator.php');
476476

477477
yield from $this->gatherAssertTypes(__DIR__ . '/data/literal-string.php');
478+
479+
yield from $this->gatherAssertTypes(__DIR__ . '/data/filter-var-returns-non-empty-string.php');
478480
}
479481

480482
/**
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace FilterVarReturnsNonEmptyString;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class Foo
8+
{
9+
/** @param non-empty-string $str */
10+
public function run(string $str): void
11+
{
12+
assertType('non-empty-string', $str);
13+
14+
$return = filter_var($str, FILTER_DEFAULT);
15+
assertType('non-empty-string|false', $return);
16+
17+
$return = filter_var($str, FILTER_SANITIZE_STRING);
18+
assertType('non-empty-string|false', $return);
19+
20+
$str2 = '';
21+
$return = filter_var($str2, FILTER_DEFAULT);
22+
assertType('string|false', $return);
23+
}
24+
}

0 commit comments

Comments
 (0)