Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83059 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7246 invoked from network); 18 Feb 2015 13:02:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 13:02:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=francois@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=francois@php.net; 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:8192] helo=smtp2-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/4F-18888-08D84E45 for ; Wed, 18 Feb 2015 08:02:57 -0500 Received: from moorea (unknown [82.240.16.115]) by smtp2-g21.free.fr (Postfix) with ESMTP id 3EC534B023C; Wed, 18 Feb 2015 14:02:33 +0100 (CET) Reply-To: To: "'Andrey Andreev'" , "'Lester Caine'" Cc: References: <54E3E27B.2010903@lerdorf.com> <2f99c47df51fa6c73131032ec50fade0@mail.gmail.com> <54E46171.3010805@lsces.co.uk> In-Reply-To: Date: Wed, 18 Feb 2015 14:02:50 +0100 Message-ID: <030e01d04b7b$33bcdba0$9b3692e0$@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: AQKz6wpj8b81mnwJq1LfxWbU4ZJyQgGjcksIAbrU1N8Bn0wufQGLyLi6AmixSwcCFGxi7gFUJDhrmsxDeJA= Content-Language: fr X-Antivirus: avast! (VPS 150217-2, 17/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 : Andrey Andreev [mailto:narf@devilix.net] > > Consider the following signature: >=20 > function foo(int $bar) {} >=20 > In the case of a *string* representation of a hexadecimal number, the > following would error only on the last iteration with a weak hint, and > on the very first if it was a strict hint: >=20 > for ($i =3D 0; $i < 11; $i++) > { > foo(base_convert($i, 10, 16)); > } You're right. An hexa string with no leading '0x' and containing decimal = digits only cannot be recognized as hexa. But I keep thinking that, = balancing pros and cons, it's not enough to justify strict mode. Maybe = I'm wrong and additional use cases will make me change my mind, but I = consider hexa with no prefix as an edge-case. I don't say that's the right solution but the problem can be solved at = the base_convert() level. If we support '0x' strings as hexadecimal = numbers, it can generate the '0x' prefix, which removes ambiguity for = PHP and any other software that would have to interpret the string. = Unfortunately, it would probably have to be explicitly required through = an option because of BC. No perfect solution here. Another argument some may consider weak : I'm also afraid that, in your = example, the user seeing an error raised by strict mode could change its = code to 'foo((int)base_convert', definitely hiding the real bug, even = for 11 and up. So, Rasmus is right when he says strict mode can = sometimes and indirectly be counter-productive. Debugging shouldn't be = considered as error suppression only, but it is the case more than = often. Regards Fran=C3=A7ois