Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98481 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60530 invoked from network); 11 Mar 2017 13:53:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Mar 2017 13:53:15 -0000 Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 74.125.82.181 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 74.125.82.181 mail-ot0-f181.google.com Received: from [74.125.82.181] ([74.125.82.181:34391] helo=mail-ot0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/C1-38004-94104C85 for ; Sat, 11 Mar 2017 08:53:14 -0500 Received: by mail-ot0-f181.google.com with SMTP id o24so91509344otb.1 for ; Sat, 11 Mar 2017 05:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=cizA3Wr6AOkpPYGdCKrNQeRukXQDgm1AvjrpVi0u5oo=; b=ke9Ucm5wa91ZhGJk1MQf4iKiPF5N9WKV0xyPy+AO4+LVwgMCuWfUM8zsDmLkcDJd+t 8QEiNXzY5X0llnMPzgrSI4M8xaBvzBo+a8ClGlvBj2rmOQwee+oG9ZtJTk1eRhGBpVVH BikurItl2ZKXso3mUFtMeKizKtU/QRNliHUlU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=cizA3Wr6AOkpPYGdCKrNQeRukXQDgm1AvjrpVi0u5oo=; b=esJ+ql/eTRk57kQIVXET0IC96MlO5i07Kc0N+W1F8rTRsB0ID3knGI/bogEDyArgM7 9+48YPaKth/QYDIEaqW9nlY8Z1hUB0gAH4dtHk7p3yvyaLEjfYu7GQEYEmrtuQ78+9ep fGETz7qYBF4c7dqAeAH+AbAwPEs8KDA2N8bzHhlMc75eBRUJNIyxAPdWEVdfVntLtwMA 70TI6rShVMjdjk9FckzS7jyDaGQI8ECq2n1aywjEIUOFEqu8H9+TLuU5BnwLrGb9iDTK g3sPHa5PJCDGrCK9isLwz6cO5YavgKhyih9x1dNnHlRxaegR8+tKKgcpQuKuKmZdLXPb ugdQ== X-Gm-Message-State: AFeK/H0V3HJRaTpN2ug6PZ3Tyr+FXrK03x4hWjOLQAHWkwZMesTAi2NdIg7I+fiXQxmLpRofblVvgRvvmVtn8w== X-Received: by 10.157.63.118 with SMTP id m109mr11398339otc.270.1489240390985; Sat, 11 Mar 2017 05:53:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.242.83 with HTTP; Sat, 11 Mar 2017 05:53:10 -0800 (PST) In-Reply-To: <6BDFA788-B52E-42BE-8794-50959D3A81BE@gmail.com> References: <24efb0e7-b0e3-68ed-5f42-2d5481f8f291@gmail.com> <44add374-6c4b-399a-c542-8d7f100dfaa3@fleshgrinder.com> <2AB030D8-9677-4E0E-8215-07D77910E51B@gmail.com> <6BDFA788-B52E-42BE-8794-50959D3A81BE@gmail.com> Date: Sat, 11 Mar 2017 15:53:10 +0200 Message-ID: To: Rowan Collins Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: narf@devilix.net (Andrey Andreev) On Sat, Mar 11, 2017 at 3:34 PM, Rowan Collins wrote: > On 11 March 2017 13:23:16 GMT+00:00, Andrey Andreev wrote: >>Ironically enough, the following code executes silently: >> >> $array = ['a', 'b', 'c']; >> sort($array, '2234234324'); >> >>If you don't see the problem with that, I guess it does make "no sense >>at all" from your POV. Just agree to disagree. > > > I see a problem with that, but I see exactly the same problem with this: > > $array = ['a', 'b', 'c']; > sort($array, 2234234324); > > The fact is, "int" is far too loose a type constraint to meaningfully validate that parameter. The solution to that is not to be more strict in rejecting strings, but to create richer types of constraint: enums, unions, domains, etc. > I don't disagree with that in general, but strictly rejecting strings and other non-integer values would alleviate the problem for a majority of cases; i.e. would solve the 90% problem. What I strongly disagree on is that I should be happy with coercion, and the almost religious resistance against (non-overridable) strict scalar typing. Cheers, Andrey.