-
Notifications
You must be signed in to change notification settings - Fork 504
/
Copy pathstrlen-never.php
50 lines (43 loc) · 966 Bytes
/
strlen-never.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace StrlenNever;
use function PHPStan\Testing\assertType;
/**
* @param non-empty-string $nonES
* @param non-falsy-string $nonFalsy
* @param numeric-string $numericString
* @param lowercase-string $lower
* @param uppercase-string $upper
*/
function doFoo(string $s, $nonES, $nonFalsy, $numericString, $lower, $upper) {
if (strlen($s) <= 0) {
assertType("''", $s);
}
if (strlen($nonES) <= 0) {
assertType('*NEVER*', $nonES);
}
if (strlen($nonFalsy) <= 0) {
assertType('*NEVER*', $nonFalsy);
}
if (strlen($numericString) <= 0) {
assertType("*NEVER*", $numericString);
}
if (strlen($lower) <= 0) {
assertType("''", $lower);
}
if (strlen($upper) <= 0) {
assertType("''", $upper);
}
if (strlen($nonES) >= 0) {
assertType('non-empty-string', $nonES);
} else {
assertType('*NEVER*', $nonES);
}
}
function doBar(string $m): void
{
if (strlen($m) >= 1) {
if (strlen($m) <= 0) {
assertType('*NEVER*', $m);
}
}
}