|
8 | 8 | use function tag_exists; |
9 | 9 | use function PHPStan\Testing\assertType; |
10 | 10 |
|
11 | | -$term = $_GET['term'] ?? 123; |
12 | | -$taxo = $_GET['taxo'] ?? 'category'; |
| 11 | +$termStr = Faker::string(); |
| 12 | +$termInt = Faker::int(); |
| 13 | +$termIntStr = Faker::union(Faker::int(), Faker::string()); |
13 | 14 |
|
14 | 15 | // Empty taxonomy |
15 | 16 | assertType('string|null', term_exists(123)); |
16 | 17 | assertType('string|null', term_exists(123, '')); |
17 | | -assertType('0|string|null', term_exists($term)); |
18 | | -assertType('0|string|null', term_exists($term, '')); |
| 18 | +assertType('string|null', term_exists($termStr)); |
| 19 | +assertType('string|null', term_exists($termStr, '')); |
| 20 | +assertType('0|string|null', term_exists($termInt)); |
| 21 | +assertType('0|string|null', term_exists($termInt, '')); |
| 22 | +assertType('0|string|null', term_exists($termIntStr)); |
| 23 | +assertType('0|string|null', term_exists($termIntStr, '')); |
19 | 24 |
|
20 | 25 | // Fixed taxonomy string |
21 | 26 | assertType('array{term_id: string, term_taxonomy_id: string}|null', term_exists(123, 'category')); |
22 | | -assertType('0|array{term_id: string, term_taxonomy_id: string}|null', term_exists($term, 'category')); |
| 27 | +assertType('array{term_id: string, term_taxonomy_id: string}|null', term_exists($termStr, 'category')); |
| 28 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|null', term_exists($termInt, 'category')); |
| 29 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|null', term_exists($termIntStr, 'category')); |
23 | 30 |
|
24 | 31 | // Unknown taxonomy type |
25 | | -assertType('array{term_id: string, term_taxonomy_id: string}|string|null', term_exists(123, $taxo)); |
26 | | -assertType('0|array{term_id: string, term_taxonomy_id: string}|string|null', term_exists($term, $taxo)); |
27 | | -assertType('null', term_exists('', $taxo)); |
| 32 | +$taxonomy = (string)$_GET['taxonomy'] ?? ''; |
| 33 | +assertType('array{term_id: string, term_taxonomy_id: string}|string|null', term_exists(123, Faker::string())); |
| 34 | +assertType('array{term_id: string, term_taxonomy_id: string}|string|null', term_exists($termStr, $taxonomy)); |
| 35 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|string|null', term_exists($termInt, Faker::string())); |
| 36 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|string|null', term_exists($termIntStr, Faker::string())); |
28 | 37 |
|
29 | 38 | // Term 0 |
30 | 39 | assertType('0', term_exists(0)); |
31 | 40 | assertType('0', term_exists(0, '')); |
32 | 41 | assertType('0', term_exists(0, 'category')); |
33 | | -assertType('0', term_exists(0, $taxo)); |
| 42 | +assertType('0', term_exists(0, Faker::string())); |
34 | 43 |
|
35 | 44 | // Term empty string |
36 | 45 | assertType('null', term_exists('')); |
37 | 46 | assertType('null', term_exists('', '')); |
38 | 47 | assertType('null', term_exists('', 'category')); |
39 | | -assertType('null', term_exists('', $taxo)); |
| 48 | +assertType('null', term_exists('', Faker::string())); |
40 | 49 |
|
41 | 50 | // tag_exists() |
42 | | -assertType('array{term_id: string, term_taxonomy_id: string}|null', tag_exists(123)); |
43 | | -assertType('0|array{term_id: string, term_taxonomy_id: string}|null', tag_exists($term)); |
44 | 51 | assertType('0', tag_exists(0)); |
45 | 52 | assertType('null', tag_exists('')); |
| 53 | +assertType('array{term_id: string, term_taxonomy_id: string}|null', tag_exists(123)); |
| 54 | +assertType('array{term_id: string, term_taxonomy_id: string}|null', tag_exists($termStr)); |
| 55 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|null', tag_exists($termInt)); |
| 56 | +assertType('0|array{term_id: string, term_taxonomy_id: string}|null', tag_exists($termIntStr)); |
0 commit comments