Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83128 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60269 invoked from network); 18 Feb 2015 22:13:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 22:13:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=patrickallaert@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wg0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:57023] helo=mail-wg0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/2D-25021-59E05E45 for ; Wed, 18 Feb 2015 17:13:41 -0500 Received: by mail-wg0-f51.google.com with SMTP id y19so3835263wgg.10 for ; Wed, 18 Feb 2015 14:13:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:references:from:date:message-id:subject:to :content-type; bh=TC3ornIVyPG0LhWCRlTzyDfnxUxjSIml+B8thRMozkQ=; b=NWm4DbwDFVFwsbk5Mg0K/ncZTdxbj6sLHcqEiYRcGqrS4eGmUPjXqPya5wTsWwLXw+ jKe2GQwZNnc/ObnDl0Sjvp0d3sDvV+ykIWdCDjzE8RjHnvbdi52DCxIcmsGpOB2s7lR5 41uo7ltN0AkPsi6AxXPgOjg4bhWGPRrLxY5Bl+ssJ7fyg6YwyTYvvgONpipp5BPArrjJ 1m/eaxXCMwDIWYFiJNNbltZ3/KLw69pn+Xzjvaz9vNdKjsM+TSVubsW6lgcYaTcCKe6p iw2AcpgsAbcTVZje6NVZntsEH+2rHlBDJ0W1UcAf4QeGpjGOpmcO5RYtgwQU0yYN5mt9 TI/g== X-Received: by 10.194.157.68 with SMTP id wk4mr2693496wjb.123.1424297618523; Wed, 18 Feb 2015 14:13:38 -0800 (PST) MIME-Version: 1.0 References: <035001d04ba1$32cdf280$9869d780$@php.net> Date: Wed, 18 Feb 2015 22:13:37 +0000 Message-ID: To: francois@php.net, Sara Golemon , PHP internals Content-Type: multipart/alternative; boundary=089e0112cbfc9b4e94050f642102 Subject: Re: [PHP-DEV] Scalar Type Hints v0.4 From: patrickallaert@php.net (Patrick ALLAERT) --089e0112cbfc9b4e94050f642102 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Le Wed Feb 18 2015 at 18:35:02, Fran=C3=A7ois Laupretre = a =C3=A9crit : > > De : Patrick ALLAERT [mailto:patrickallaert@php.net] > > ini_set("coercion_reporting", COERCION_ERROR); // Fail in case of > > potentially bad coercion > > > > foo(7); > > // int(7) > > foo("7"); > > // int(7) > > foo("7 dogs"); > > // Catchable fatal error: Unsafe coercion transforming "7 dogs" to > "7". > > > > The biggest advantage, IMHO, is that you get the exact same result > whether > > you do: > > > > foo((int) $value); > > > > or: > > > > foo($value); > > > > ... whatever the mode you are in. > > > > 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). > > > > 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. > Does it sounds like a "compromise"? ;) More seriously, I'm not sure that should be a prerequisite for accepting an RFC. Patrick --089e0112cbfc9b4e94050f642102--