Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101968 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66296 invoked from network); 12 Mar 2018 16:43:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Mar 2018 16:43:25 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.216.171 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.171 mail-qt0-f171.google.com Received: from [209.85.216.171] ([209.85.216.171:45996] helo=mail-qt0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F6/3E-24487-B2EA6AA5 for ; Mon, 12 Mar 2018 11:43:23 -0500 Received: by mail-qt0-f171.google.com with SMTP id v90so19478295qte.12 for ; Mon, 12 Mar 2018 09:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=jCD1n2SQzyfOoFtahFKn4I9+huU40uBvKcidnc1WBLM=; b=soDJz3FGFIIDZsht0wmWIZCnYlAW0iCGEcbStSAKJPrWp5NMqYh3VTqVp9I3UizlKC w4NUpWpeW0miEDhXLuXZNvNy9kyV8pKNbY5ANPkLk2AvIngZVSnYBLX6jy5MgtFSUJwk jlis/KHXItzk0MlCp12PZ4HZFb3scb9f0umP/t/dsiKSgCEQvcePs7vx2F/Ahjt8hIIU BlQpHidgaVJ6QOl8w6vTeKMN2dyx4H/O2fC0IOGVS6B+t5dXfcwlMRJVunCpCHnTyJJ8 X8M3A3p0A6O5Ga17Akhm7VsfwTQrnjmM6xMZUyAJXFiD6rIbB1t84UiFe/QMcBzLzv5f s6kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=jCD1n2SQzyfOoFtahFKn4I9+huU40uBvKcidnc1WBLM=; b=moX6VfntVkYO+v/HE+X1hMXYf80JhNIBmzLm8PcDuCFWkAaEadjDxa/dTm/yBBH2w1 fMehMHXgOqg9PVtzO2Ezwju0mP5+BSO1hPPiK06EfZRzvC2PXrmqrZM+m0OCh7EVuu+/ TKZv9pG5Yut7fDfe+6V1//P6IkQgEvkHHqbevhppFtsTy56Q5wIwrXZGOMYyABx1fmMC /f5iv2fNI2+RmnFaHgCBUwoW4IwXyGSAer84grkkN99wGomnYvHqG+bkAFjR8HJKxUgk QQMY6hDQvnG85tRzP0ffvhhHZF8TSW4QpuMSLeAIwBWeWhVAL6urk3Efi5rGi3khpE1A uQqg== X-Gm-Message-State: AElRT7H25wIEMCY/XTSaTAYMi6bVx4sydug4gJcqDnbiQG89CcDn+dOg 9YZS5g9jsWRIxfpcGfkCg0q/w30/awrXM1WRCGR/jA== X-Google-Smtp-Source: AG47ELuq/kDN87Da0BlPl9Km5FS9mgsFtUOyBQV4wejzAVBc+Qu5pYsXvYMhM7WZSFV4v2Db4owDh2bCnfsLdUWiBaM= X-Received: by 10.200.53.137 with SMTP id k9mr12925149qtb.37.1520873000273; Mon, 12 Mar 2018 09:43:20 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.155.169 with HTTP; Mon, 12 Mar 2018 09:43:19 -0700 (PDT) X-Originating-IP: [206.252.215.26] In-Reply-To: References: <1e29d1b7-dbf4-35d5-61cc-8348c195984a@gmx.de> Date: Mon, 12 Mar 2018 12:43:19 -0400 X-Google-Sender-Auth: BkDG9X1U1XkF7Yk6VwaHFVhPeVc Message-ID: To: "Christoph M. Becker" Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [RFC] Base Conversion Clowniness From: pollita@php.net (Sara Golemon) On Mon, Mar 12, 2018 at 11:32 AM, Christoph M. Becker 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