Commit a6ae1eb
Chirag Aggarwal
fix: preserve empty-string sentinel in coerce()
Optional params with `--flag=` (or default `''`) bypass `validate()`
entirely, so they reach `coerce()` un-validated. The previous version
ran them through `filter_var($value, FILTER_VALIDATE_BOOLEAN)`, which
silently returns `false` for empty strings -- a behaviour change for
callers (e.g. Cloud's `Patch.php`) that use `''` as a three-state
"not set" sentinel before resolving to `null`.
Now coerce returns early for empty strings, and uses
`FILTER_NULL_ON_FAILURE` for everything else so any unrecognised
input falls back to the original value rather than getting
silently downgraded to `false`.
Spotted by Greptile review on PR #52.1 parent 8686789 commit a6ae1eb
2 files changed
Lines changed: 34 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
428 | 431 | | |
429 | 432 | | |
430 | 433 | | |
431 | 434 | | |
432 | 435 | | |
433 | 436 | | |
434 | 437 | | |
435 | | - | |
| 438 | + | |
436 | 439 | | |
437 | 440 | | |
438 | 441 | | |
| |||
444 | 447 | | |
445 | 448 | | |
446 | 449 | | |
447 | | - | |
448 | | - | |
| 450 | + | |
| 451 | + | |
449 | 452 | | |
450 | 453 | | |
451 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
452 | 457 | | |
453 | 458 | | |
454 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
367 | 391 | | |
368 | 392 | | |
369 | 393 | | |
| |||
0 commit comments