Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98470 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97446 invoked from network); 10 Mar 2017 14:20:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Mar 2017 14:20:37 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.67 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.67 mail-wm0-f67.google.com Received: from [74.125.82.67] ([74.125.82.67:36457] helo=mail-wm0-f67.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/46-31244-436B2C85 for ; Fri, 10 Mar 2017 09:20:36 -0500 Received: by mail-wm0-f67.google.com with SMTP id v190so2531006wme.3 for ; Fri, 10 Mar 2017 06:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=PTnFMFd7LtH2hIeSjUnDOXkt03QFDO5pofbX6HjdN6Y=; b=h2RRXbg+Pf5aw2WjHUT2e5WMm4Z9eaDrS0GAHz3x3WTiIif9BqqjHsunmH+xeKa7HI +YphFjeeEhmpr79xifOy9Am+Uj93YLQQndLxon4oNjs8Ga9UeLbAcmjs4c2Gi+Gj38mv RTFqRp12tCD+irMFYLdI8DV9GmzwudSD/2M81qmUu9cJ9Ty3d7g3t9gODfbe1Jo8yFnx xyJnZZ5P4fuy0BnNQ2glJ3f5xGKCZsNRbYs+xQn25K2uROrMGtkWMar20bRsfQL3gFV4 8vsQ1X+oSI8EqMce09mGNLnD+xFGZ2lAnqQxnb5jG/Wp5FycdwJQnEkXKh6Vn6qzmIJw MduA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=PTnFMFd7LtH2hIeSjUnDOXkt03QFDO5pofbX6HjdN6Y=; b=qYV0Nrqiq91mvpmEH+++s3xn6sQ3byU+Gp5IMPeFq0IUX6xEE4FrlqzwQw2xpy6KWn +JSmSSYbEM1WNj8cijIcwCQWaZTgdq+I6LWOvLjhXmdVvhs2KNzucGQX6yH4IWUWbNFh +THRAa23Fc2argU2jKUpAgBeGF9dElI2y6ZQKNzmNh/1JWNZLQT2aS3WHfBTfjjshjyv iZDDXJIEcvDX/xJlj/JNENaAvD/LBYEskAdKYe7G5UC0TBI2HLk+O2bn16L0klXxG3XQ qSSM+u4KVv5b9ie71xVdiOrkBaOuIlkUveqJdO14jMlUdatDErtlxfwFrgnN1Yi+ULot saiw== X-Gm-Message-State: AFeK/H36XtVOrmQz+3iZYvQ4Lzo7DiwanR/vWNkVs9hSCly6vGlkDjkJDDBqsit2iRlrww== X-Received: by 10.28.218.80 with SMTP id r77mr2620918wmg.0.1489155633167; Fri, 10 Mar 2017 06:20:33 -0800 (PST) Received: from [10.60.124.86] (188.29.164.180.threembb.co.uk. [188.29.164.180]) by smtp.gmail.com with ESMTPSA id b10sm3500026wmi.34.2017.03.10.06.20.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2017 06:20:31 -0800 (PST) Date: Fri, 10 Mar 2017 14:20:28 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: <24efb0e7-b0e3-68ed-5f42-2d5481f8f291@gmail.com> <44add374-6c4b-399a-c542-8d7f100dfaa3@fleshgrinder.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net,Andrey Andreev Message-ID: Subject: Re: [PHP-DEV] [Discussion] is_string(), string type and objects implementing __toString() From: rowan.collins@gmail.com (Rowan Collins) On 10 March 2017 10:57:42 GMT+00:00, Andrey Andreev wr= ote: >I'm not really interested in making "strict mode" less strict - it's >already opt-in and non-enforceable=2E >I want ways to write stonger-type code in "non-strict mode", because >the fact that "strict mode" is non-enforceable means I can never rely >on it=2E This is a common misconception - you can absolutely rely on strict mode en= forcing your contract=2E Basically all that happens in non-strict mode is that if the caller writes= : foo($value); The compiler automatically changes that to: foo((string)$value); (That's not literally how it's implemented, but it's the effect you get=2E= ) As the receiver of that parameter, you can't tell, and don't care, if it w= as the human writing the code who added the cast, or the compiler adding it= for them=2E You can't detect someone blindly writing "(string)" everywhere any more th= an you can detect whether they are running in strict mode=2E Nor can you kn= ow if they took it straight from unfiltered user input, or copy-pasted a li= teral string to 10 different files, or a hundred other things you'd really = like them not to do=2E All you know is, you asked for a string, and you got= one=2E Regards, --=20 Rowan Collins [IMSoP]