|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Bug14047; |
| 4 | + |
| 5 | +use function is_numeric; |
| 6 | +use function PHPStan\Testing\assertType; |
| 7 | + |
| 8 | +function test_strings(string $a, string $b): void |
| 9 | +{ |
| 10 | + if (strtolower($a) !== $b) { |
| 11 | + assertType('string', $a); |
| 12 | + assertType('string', $b); |
| 13 | + } |
| 14 | + |
| 15 | + if ($a !== '' && strtolower($a) == $b) { |
| 16 | + assertType('non-empty-string', $a); |
| 17 | + assertType('lowercase-string&non-empty-string', $b); |
| 18 | + } |
| 19 | + |
| 20 | + if ($a !== '' && strtolower($a) === $b) { |
| 21 | + assertType('non-empty-string', $a); |
| 22 | + assertType('lowercase-string&non-empty-string', $b); |
| 23 | + } |
| 24 | + |
| 25 | + if ($a !== '' && strtolower($a) == $b && $b !== '0') { |
| 26 | + assertType('non-empty-string', $a); |
| 27 | + assertType('lowercase-string&non-falsy-string', $b); |
| 28 | + } |
| 29 | + |
| 30 | + if ($a !== '' && strtolower($a) === $a) { |
| 31 | + assertType('lowercase-string&non-empty-string', $a); |
| 32 | + } elseif ($a !== '' && strtoupper($a) === $a) { |
| 33 | + assertType('non-empty-string&uppercase-string', $a); |
| 34 | + } |
| 35 | + |
| 36 | + if ($a !== '') { |
| 37 | + if (strtolower($a) === $a) { |
| 38 | + assertType('lowercase-string&non-empty-string', $a); |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + if (strtolower($b) === $b && $b !== '') { |
| 43 | + assertType('lowercase-string&non-empty-string', $b); |
| 44 | + } elseif (strtoupper($b) === $b && $b !== '') { |
| 45 | + assertType('non-empty-string&uppercase-string', $b); |
| 46 | + } |
| 47 | + |
| 48 | + if ($b !== '' && is_numeric($b)) { |
| 49 | + assertType('non-empty-string&numeric-string', $b); |
| 50 | + } |
| 51 | + |
| 52 | + if (strtolower($b) === $b && $b !== '' && is_numeric($b)) { |
| 53 | + assertType('lowercase-string&non-empty-string&numeric-string', $b); |
| 54 | + } |
| 55 | + |
| 56 | + assertType('string', $b); |
| 57 | + if (is_numeric($b)) { |
| 58 | + assertType('numeric-string', $b); |
| 59 | + if (strtolower($b) === $b) { |
| 60 | + assertType('lowercase-string&non-empty-string&numeric-string', $b); |
| 61 | + if ($b !== '') { |
| 62 | + assertType('lowercase-string&non-empty-string&numeric-string', $b); |
| 63 | + } |
| 64 | + } |
| 65 | + if ($b !== '') { |
| 66 | + assertType('numeric-string', $b); |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments