Commit ef4bfa7
committed
bug #637 [Php83][Php85][Grapheme] Throw ValueError on PHP 7 for functions that never returned false (nicolas-grekas)
This PR was merged into the 1.x branch.
Discussion
----------
[Php83][Php85][Grapheme] Throw ValueError on PHP 7 for functions that never returned false
| Q | A
| ------------- | ---
| Branch? | 1.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix #636
| License | MIT
`grapheme_levenshtein()` (8.5), `grapheme_str_split()` (8.4), `json_validate()`, `str_increment()` and `str_decrement()` (8.3) throw a `ValueError` for invalid arguments. Unlike the mbstring family, these functions were never designed to return `false`, so the polyfills should reproduce the exception on every supported PHP version.
On PHP < 8 they either returned `false` (grapheme) or referenced the missing `ValueError` class, which fatals unless `polyfill-php80` happens to be installed (the case reported in #636). Each affected bootstrap now declares a guarded `ValueError` stub on PHP < 8, the same way the Apcu polyfill declares `APCuIterator`, and the functions throw on all versions.
The mbstring functions (including `mb_str_pad`) keep their `trigger_error()` + `false` behavior on PHP < 8, which matches how the extension behaves there.
Commits
-------
c7304c2 [Php83][Php85][Grapheme] Throw ValueError on PHP 7 for functions that never returned false6 files changed
Lines changed: 49 additions & 10 deletions
File tree
- src
- Intl/Grapheme
- Php83
- Php85
- tests
- Intl/Grapheme
- Php85
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | 200 | | |
205 | 201 | | |
206 | 202 | | |
| |||
232 | 228 | | |
233 | 229 | | |
234 | 230 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 231 | | |
240 | 232 | | |
241 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
221 | 231 | | |
222 | 232 | | |
223 | 233 | | |
| |||
288 | 298 | | |
289 | 299 | | |
290 | 300 | | |
291 | | - | |
292 | | - | |
293 | 301 | | |
294 | 302 | | |
295 | 303 | | |
296 | 304 | | |
| 305 | + | |
297 | 306 | | |
298 | 307 | | |
299 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
157 | 177 | | |
158 | 178 | | |
159 | 179 | | |
| |||
0 commit comments