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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! PHP standard-library `ctype` functions. Part of the `stdlib` chain; see
//! `src/stdlib/mod.rs`. `dispatch` returns `None` for names it does not handle.
//!
//! Each `ctype_*` predicate classifies a value in the C locale (bytes 0-255):
//! * A string passes iff it is non-empty and *every* byte satisfies the class
//! (an empty string is always `false`).
//! * An integer in `-128..=255` is a single character code (negatives get 256
//! added, matching PHP's extended-ASCII handling).
//! * Any other integer is classified as its decimal-string representation.
//! * Any other value type yields `false`.
//!
//! A non-string argument additionally raises `Argument of type T will be
//! interpreted as string in the future` (E_DEPRECATED, PHP 8.1+); the
//! classification above is still what is returned.
//!
//! This mirrors PHP 8's `ext/ctype`, whose macros call the C `is*` functions on
//! `unsigned char`, so only the ASCII range (< 0x80) can satisfy any class.
use cratewith_host;
use cratearg;
use Value;
// --- C-locale byte predicates (ASCII only; bytes >= 0x80 satisfy none) ---
/// C `isspace`: space, `\t`, `\n`, `\v`, `\f`, `\r`. Note Rust's
/// `is_ascii_whitespace` omits `\v` (0x0B), so it cannot be used here.
/// C `iscntrl`: 0x00-0x1F and 0x7F.
/// C `isgraph`: printable, non-space (0x21-0x7E).
/// C `isprint`: printable including space (0x20-0x7E).
/// C `ispunct`: graphic and not alphanumeric.
/// `zend_zval_type_name` spelling of a non-string argument, as the ctype
/// deprecation prints it.
/// Apply `pred` under PHP `ctype` argument rules and return a PHP bool.
/// Dispatch a `ctype`-category PHP function by lowercased name.