Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80445 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51306 invoked from network); 14 Jan 2015 08:22:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jan 2015 08:22:53 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:59119] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5A/D0-43840-A5726B45 for ; Wed, 14 Jan 2015 03:22:51 -0500 Received: (qmail 20724 invoked from network); 14 Jan 2015 09:22:47 +0100 Received: from cm135-167.liwest.at (HELO RoLaptop) (81.10.135.167) by ns73.kreativmedia.ch with ESMTPSA (AES256-SHA encrypted, authenticated); 14 Jan 2015 09:22:46 +0100 To: "'Andrea Faulds'" , "'PHP Internals List'" References: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> In-Reply-To: <8DCD1B72-C81D-499E-B455-E4A042CD76E6@ajf.me> Date: Wed, 14 Jan 2015 09:22:42 +0100 Message-ID: <000301d02fd3$456ab390$d0401ab0$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQGo6gmoLPH7aNIVeHjTN7HPWATOM50NyG5w Content-Language: de-ch Subject: AW: [PHP-DEV] [RFC] Scalar Type Hints v0.2 From: php@tutteli.ch ("Robert Stoll") Hi Andrea > -----Urspr=C3=BCngliche Nachricht----- > Von: Andrea Faulds [mailto:ajf@ajf.me] > Gesendet: Mittwoch, 14. Januar 2015 01:17 > An: PHP Internals List > Betreff: [PHP-DEV] [RFC] Scalar Type Hints v0.2 >=20 > Good evening, >=20 > I=E2=80=99ve made some quite significant changes to my Scalar Type = Hints RFC, and bumped its version to 0.2. >=20 > Here: https://wiki.php.net/rfc/scalar_type_hints >=20 > This is a new thread because I=E2=80=99ve made a significant revision = to the RFC, so it=E2=80=99d be sensible to separate discussion of the > updated RFC from the v0.1 RFC. >=20 > Please tell me your thoughts. >=20 > Thanks! > -- > Andrea Faulds > http://ajf.me/ >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: http://www.php.net/unsub.php I had a few thoughts on the new proposed = declare(strict_typehints=3DTRUE); construct and I must say I do not = really like that we would have different behaviour just based on a = directive. This is quite ugly from a readability point of view since I = as user cannot easily see whether somewhere (above) in the code the = directive was set (I have changed my mind a little bit below - left it = here for traceability purposes). Which brings me to the question what = happens with the following code: function foo(int $a){} //is weak right? declare(strict_typehinting=3DTRUE); I guess it is weak since you wrote: "If this boolean value is TRUE, = strict type-checking mode is used for function calls in the remainder of = the file" Maybe it is a good idea to add such an example to the examples as well. Now, having rethought my own email, I think we should enforce some code = style to avoid a huge mess. Why not declare that the directive needs to = be the very first statement inside a namespace scope (unless the = directive block syntax is used). This way it would be easily verifiable = for the user if strict mode is in place or not. But then again, we could = also argue that is up to code conventions/code guidelines and they = should specify whether mixing both modes is ok and where the directive = has to be placed. So re-rethinking what I just wrote I would say it is = fine as it is now but we should at least consider if we want to enforce = some code practice to avoid a mess. Now another point: "Whether or not the function being called was = declared in a file that uses strict or weak type checking is entirely = irrelevant. The type checking mode depends on the file where the = function is called." Seems quite strange to me but fair enough, why not -- actually makes = perfectly sense for this RFC -> leaving it to the user to decide what = he/she likes :-)=20