Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83096 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92924 invoked from network); 18 Feb 2015 17:34:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 17:34:57 -0000 Authentication-Results: pb1.pair.com header.from=francois@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 212.27.42.2 as permitted sender) X-PHP-List-Original-Sender: francois@php.net X-Host-Fingerprint: 212.27.42.2 smtp2-g21.free.fr Received: from [212.27.42.2] ([212.27.42.2:28053] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/50-25021-04DC4E45 for ; Wed, 18 Feb 2015 12:34:57 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 444AC4B0226; Wed, 18 Feb 2015 18:34:32 +0100 (CET) Reply-To: To: "'Patrick ALLAERT'" , "'Sara Golemon'" , "'PHP internals'" References: In-Reply-To: Date: Wed, 18 Feb 2015 18:34:49 +0100 Message-ID: <035001d04ba1$32cdf280$9869d780$@php.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQKz6wpj8b81mnwJq1LfxWbU4ZJyQgJsy61hmxwEguA= Content-Language: fr X-Antivirus: avast! (VPS 150218-0, 18/02/2015), Outbound message X-Antivirus-Status: Clean Subject: RE: [PHP-DEV] Scalar Type Hints v0.4 From: francois@php.net (=?utf-8?Q?Fran=C3=A7ois_Laupretre?=) > De : Patrick ALLAERT [mailto:patrickallaert@php.net] > ini_set("coercion_reporting", COERCION_ERROR); // Fail in case of > potentially bad coercion >=20 > foo(7); > // int(7) > foo("7"); > // int(7) > foo("7 dogs"); > // Catchable fatal error: Unsafe coercion transforming "7 dogs" to = "7". >=20 > The biggest advantage, IMHO, is that you get the exact same result = whether > you do: >=20 > foo((int) $value); >=20 > or: >=20 > foo($value); >=20 > ... whatever the mode you are in. >=20 > Basically, this is weak type hints + something similar to what I > contributed in the past with the "Array to string conversion" notice = (see: > https://github.com/php/php-src/commit/d81ea16e). >=20 > Care to share the pro's/con's you see with a solution like that? That's a good idea, IMO. We can add an optional message when a = conversion is executed in ZPP macros. It can help. The main drawback is = that it is pure runtime check, not suitable for static analysis and = related tools. Regards Fran=C3=A7ois