Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83066 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19283 invoked from network); 18 Feb 2015 13:31:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Feb 2015 13:31:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.214.172 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.214.172 mail-ob0-f172.google.com Received: from [209.85.214.172] ([209.85.214.172:54388] helo=mail-ob0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/B1-18888-93494E45 for ; Wed, 18 Feb 2015 08:31:38 -0500 Received: by mail-ob0-f172.google.com with SMTP id nt9so1848488obb.3 for ; Wed, 18 Feb 2015 05:31:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=tRHfLwE9LeZ2Xd7oULpyDMXPXCXWxmldvZzOgJ9tFj0=; b=VJMLlftEiDKjAXxzBUgCIlRvI4+EjJepMlMKOL2iQ9omwbhV+YNXnTGNPD1th5hLlx 7x9x+Zj/gSlHspdH8cCXqn7bWUZFD+/lPoYtcSg1vT48Sr6x4Btf6K8B8OxkNuSAgPMa +f1AQEcDkSPAqPHWkN9SVoIEVRiHAqP/gOQDQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=tRHfLwE9LeZ2Xd7oULpyDMXPXCXWxmldvZzOgJ9tFj0=; b=hQIVpOM9N6AWCW5AGvZEZFsJfBHv4xECXp5AQdN0YYFFb3XTs6qgP7UhucS2h/ZR/Y 9mKTdyGivyV7cfG1/zbKUrXtkvNZSUocTwsgVxr+Oj2CWoZi/O1TDs4ukS8QysBZd13l hNF0TfRKxoUtO1gt16xRC6d3/Dml5LpMGLJVoDhR6q3OZXNz5PBIhK1sGdGR+dOZd5+m 43K+CeuIi9f4qru9bhos788mm3cSk3LjMmaXkzDn4y+y82vU+GK7dem8jIgdcqAEv4KA Wx1ncLPCKogCZjwH5fjrsnJ2OhxrYJigdQ0f26eK1V+c5TC328tgnjy824JW0A45XB9C t0Kw== X-Gm-Message-State: ALoCoQmkerEjYn7sVvKqpaql0kcE2yB2ftpVKmzd0wxik9pw0BltRnGVghNlT4DIDsYkZuljnwvj MIME-Version: 1.0 X-Received: by 10.60.63.97 with SMTP id f1mr22035925oes.16.1424266295142; Wed, 18 Feb 2015 05:31:35 -0800 (PST) Received: by 10.202.214.205 with HTTP; Wed, 18 Feb 2015 05:31:35 -0800 (PST) In-Reply-To: <030e01d04b7b$33bcdba0$9b3692e0$@php.net> References: <54E3E27B.2010903@lerdorf.com> <2f99c47df51fa6c73131032ec50fade0@mail.gmail.com> <54E46171.3010805@lsces.co.uk> <030e01d04b7b$33bcdba0$9b3692e0$@php.net> Date: Wed, 18 Feb 2015 15:31:35 +0200 Message-ID: To: francois@php.net Cc: Lester Caine , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Scalar Type Hints v0.4 From: narf@devilix.net (Andrey Andreev) Hi Fran=C3=A7ois, On Wed, Feb 18, 2015 at 3:02 PM, Fran=C3=A7ois Laupretre = wrote: >> De : Andrey Andreev [mailto:narf@devilix.net] >> >> Consider the following signature: >> >> function foo(int $bar) {} >> >> 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: >> >> 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, balanci= ng pros and cons, it's not enough to justify strict mode. Maybe I'm wrong a= nd additional use cases will make me change my mind, but I consider hexa wi= th no prefix as an edge-case. > > I don't say that's the right solution but the problem can be solved at th= e base_convert() level. If we support '0x' strings as hexadecimal numbers, = it can generate the '0x' prefix, which removes ambiguity for PHP and any ot= her software that would have to interpret the string. Unfortunately, it wou= ld probably have to be explicitly required through an option because of BC.= No perfect solution here. > In real-world applications, base_covert() would hardly ever be the culprit and I don't want to change its current behavior. I only used base_convert() in the example because that allowed the least amount of code written to display the problem. > Another argument some may consider weak : I'm also afraid that, in your e= xample, the user seeing an error raised by strict mode could change its cod= e to 'foo((int)base_convert', definitely hiding the real bug, even for 11 a= nd up. So, Rasmus is right when he says strict mode can sometimes and indir= ectly be counter-productive. Debugging shouldn't be considered as error sup= pression only, but it is the case more than often. > Sorry, but I do consider that to be a weak argument ... We can't help users who's only concern is eliminating error messages, we can only help those that understand them. Cheers, Andrey.