On Mon, Mar 12, 2018 at 11:32 AM, Christoph M. Becker <cmbecke...@gmx.de> wrote: > I tend to prefer option C (throw a Warning, stop processing, and return > the value up to that point). Option B (throw a Warning and return FALSE > on unexpected characters) might be cleaner, but we're not that picky > elsewhere, and the return value might not even be checked, and thus > easily misinterpreted as zero. > I've also added option D: Throw an exception. It's hard to miss, even if it's inconsistent with the vast majority of our runtime library (and thus, probably a bad idea). C is certainly the most consistent with the behavior of (int) cast, but it's also error prone in other ways. See also, literally anyone who has ever been caught by invalid "numeric" user input ever. B is at least consistent with the spirit of many other standard library functions, but I agree with you that the output of it is problematic. I think we can all agree that A is a terrible option and if someone is using this as a cheap version of preg_replace('/[^0-9]/', '', $in); then they deserve to have their code break.
My vote atm, given all of the above would be B, but I'm not super happy about it. -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php