File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,8 @@ public function dataFileAsserts(): iterable
475
475
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/modulo-operator.php ' );
476
476
477
477
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/literal-string.php ' );
478
+
479
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/filter-var-returns-non-empty-string.php ' );
478
480
}
479
481
480
482
/**
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments