File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -1181,6 +1181,7 @@ public function dataFileAsserts(): iterable
1181
1181
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/bug-8752.php ' );
1182
1182
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/trait-instance-of.php ' );
1183
1183
yield from $ this ->gatherAssertTypes (__DIR__ . '/data/list-shapes.php ' );
1184
+ yield from $ this ->gatherAssertTypes (__DIR__ . '/data/bug-7607.php ' );
1184
1185
}
1185
1186
1186
1187
/**
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace Bug7607 ;
4
+
5
+ use function PHPStan \Testing \assertType ;
6
+
7
+ class HelloWorld
8
+ {
9
+ /**
10
+ * Determine if the given value is "blank".
11
+ *
12
+ * @param mixed $value
13
+ * @return bool
14
+ *
15
+ * @phpstan-assert-if-false !(null|''|array{}) $value
16
+ */
17
+ public function blank ($ value )
18
+ {
19
+ if (is_null ($ value )) {
20
+ return true ;
21
+ }
22
+
23
+ if (is_string ($ value )) {
24
+ return trim ($ value ) === '' ;
25
+ }
26
+
27
+ if (is_numeric ($ value ) || is_bool ($ value )) {
28
+ return false ;
29
+ }
30
+
31
+ if ($ value instanceof Countable) {
32
+ return count ($ value ) === 0 ;
33
+ }
34
+
35
+ return empty ($ value );
36
+ }
37
+
38
+ public function getValue (): string |null
39
+ {
40
+ return 'value ' ;
41
+ }
42
+
43
+ public function getUrlForCurrentRequest (): string |null
44
+ {
45
+ return rand (0 ,1 ) === 1 ? 'string ' : null ;
46
+ }
47
+
48
+ public function isUrl (string |null $ url ): bool
49
+ {
50
+ if ($ this ->blank ($ url = $ url ?? $ this ->getUrlForCurrentRequest ())) {
51
+ return false ;
52
+ }
53
+
54
+ assertType ('non-empty-string ' , $ url );
55
+ $ parsed = parse_url ($ url );
56
+
57
+ return is_array ($ parsed );
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments