Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84043 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69110 invoked from network); 27 Feb 2015 20:28:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2015 20:28:41 -0000 Authentication-Results: pb1.pair.com smtp.mail=damz@damz.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=damz@damz.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain damz.org designates 74.125.82.181 as permitted sender) X-PHP-List-Original-Sender: damz@damz.org X-Host-Fingerprint: 74.125.82.181 mail-we0-f181.google.com Received: from [74.125.82.181] ([74.125.82.181:46243] helo=mail-we0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/75-32582-873D0F45 for ; Fri, 27 Feb 2015 15:28:41 -0500 Received: by wevm14 with SMTP id m14so22526580wev.13 for ; Fri, 27 Feb 2015 12:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=damz.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=9G+BQuAzJzRfjMdSA6Pvhs0wNsY+zC2p4R6gBJRV+e4=; b=Qmaz6xvLYDK2N+d/dPOUZMYkb8SxBYpXZ7pfYiiDwc58W+msXInFN5xdYl1Hrvistn BeY0fRszCekGwnGGeBr0siMhCsAZINGiRnKbziNxJ2gVBK41jxqAU2YQAg8l6xVSrUUb mODMWNw9Xc6FkJGtbRgq67KcTDVIVb2dAX1Yw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=9G+BQuAzJzRfjMdSA6Pvhs0wNsY+zC2p4R6gBJRV+e4=; b=EkJUw27Edg6Nq/YBf0/MBtiAxHHTbZUORE583dN/mY2p0FqrlHhgPPA3e2WSQOan38 d8q6udh7PrGzvfGbdyZLpeH6F6LbwQbIuQKgiJN50LJLg9m4t6lGuRCIYIIaM1jVTKZd jSnYeok40yE8Y2FDNydrd4LtIT+HS+mcuMy8rcA4EgKyMETv5tCanLaQ/tD2yCbrniBA C0qKwrPLrSoX6r57pJdbvrN4y+85eBc+IJQLO7QwfdcWHuDtlAv+m9VUZ7w44WDwmwNs 3vFx0rfZfnf84Js94cKSQSx8l9VPoI/lg1RMetnU7jx8Q32rCqnXuNtFxHKjq4ixcbE3 LkBw== X-Gm-Message-State: ALoCoQnX5cxFkKYgTt0/qqr/DiitHxO/1NHTWkqofbQ4qhBGc8x4TsTSPvGdhnuI86+gCUO4EEJH MIME-Version: 1.0 X-Received: by 10.180.207.84 with SMTP id lu20mr9929745wic.17.1425068918351; Fri, 27 Feb 2015 12:28:38 -0800 (PST) Received: by 10.28.181.131 with HTTP; Fri, 27 Feb 2015 12:28:38 -0800 (PST) X-Originating-IP: [78.126.234.166] In-Reply-To: <54F0AE90.4020508@lsces.co.uk> References: <4ED7146272E04A47B986ED49E771E347D3111ACD71@Ikarus.ameusgmbh.intern> <54F0AE90.4020508@lsces.co.uk> Date: Fri, 27 Feb 2015 21:28:38 +0100 Message-ID: To: Lester Caine Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c39cf4a8c090051017b616 Subject: Re: [PHP-DEV] Coercive STH - some real world tests and updated RFC From: damz@damz.org (Damien Tournoud) --001a11c39cf4a8c090051017b616 Content-Type: text/plain; charset=UTF-8 Hi Lester, On Fri, Feb 27, 2015 at 6:51 PM, Lester Caine wrote: > This may not be what YOU want substr to do and it would perhaps be > useful to ADD additional checks so that 'false' is returned when it > can't created a string because of the 'invalid arguments', but type > hints makes no difference to part of the jigsaw. What happens is exactly > what one would expect ... nothing left in the string -> an empty string. > Having then to check every time for a '0' string length got shortened to > simply being able to check 'is there a string' yes/no, and if no you can > do something else. There is nothing inconsistent ... > Please, read the examples again, the current behavior is nothing but inconsistent: substr("a", 1) => FALSE substr("a", -300) => "" But anyway, that's not even the point. The point is that return values that "worked" in a world of transparent type-jungling will not work in a world of stricter typing checks. Which means that we need: (1) To accept that for now casting FALSE to the empty string is the right thing to do; until / unless: (2) We fixed all the common functions in the standard library so that they stop returning inconsistent types, in particular in the cases where it should not even be a debate what is the right thing to do (for substr, if the arguments point to an empty slice, return the empty string). Damien --001a11c39cf4a8c090051017b616--