Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85188 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21724 invoked from network); 18 Mar 2015 12:52:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2015 12:52:31 -0000 Authentication-Results: pb1.pair.com header.from=pajousek@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pajousek@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.47 as permitted sender) X-PHP-List-Original-Sender: pajousek@gmail.com X-Host-Fingerprint: 209.85.192.47 mail-qg0-f47.google.com Received: from [209.85.192.47] ([209.85.192.47:35427] helo=mail-qg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/E5-22462-F0579055 for ; Wed, 18 Mar 2015 07:52:31 -0500 Received: by qgez64 with SMTP id z64so35192645qge.2 for ; Wed, 18 Mar 2015 05:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=EiRYqxsJ6ct1mpU+7H7beEXL/j3MVExHgBOIe4vZLCU=; b=Jpuchy797VA28ul0tBsSYv8x8aKBEm7c8suo9YisPNnxo5YdAQ8doSMDTPIPjJ9LaI D9ccVkMx5tUctd7Yy4VtW0KguyygJ+shDo8j8BFhecTLK01u7bRiC/celUTC5OThf2rT SLGb3zzmS2AbA26UXDwvYoJotlb+W/UFCKMpvmJoOagvxZxMt1RdAr2ZX+lV7tv2DnOe VPTwsaKANYQTk7i0yCrm+nmQzsb5vmHRqZ8XcZf71s+caNaT16FSJ17bdR6HofIc2qV1 KBasnFUG2ViLyS/kcg3OMPBk5uVM3+by2KlxpVoxgI2wgCq9wHylPDf08qkGeYi2lIZS euig== MIME-Version: 1.0 X-Received: by 10.55.15.159 with SMTP id 31mr88108183qkp.29.1426683148654; Wed, 18 Mar 2015 05:52:28 -0700 (PDT) Received: by 10.96.160.99 with HTTP; Wed, 18 Mar 2015 05:52:28 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Mar 2015 13:52:28 +0100 Message-ID: To: Nikita Nefedov Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Accepted] Scalar Type Declarations V0.5 From: pajousek@gmail.com (=?UTF-8?Q?Pavel_Kou=C5=99il?=) On Wed, Mar 18, 2015 at 1:13 PM, Nikita Nefedov wrote: > > On 18 Mar 2015 14:32, "Pavel Kou=C5=99il" wrote: >> >> On Wednesday, March 18, 2015, Patrick ALLAERT >> wrote: >> > Le mer. 18 mars 2015 =C3=A0 10:56, Pavel Kou=C5=99il a =C3=A9crit >> > : >> >> >> >> Hello, >> >> >> >> how will these examples work btw? >> >> >> >> // a.php >> >> > >> declare(strict_types=3D1); >> >> function foo($fn) { >> >> $fn("1"); >> >> }; >> >> >> >> // b.php >> >> > >> require 'a.php'; >> >> foo(function (int $a) { return $a * 2; }); >> >> >> >> >> >> >> >> // c.php >> >> > >> function foo($fn) { >> >> $fn("1"); >> >> }; >> >> >> >> // d.php >> >> > >> declare(strict_types=3D1); >> >> require 'c.php'; >> >> foo(function (int $a) { return $a * 2; }); >> >> >> >> I can't find this in the RFC. I'd intuitively expect error in the >> >> first example and the second one to work OK. >> > >> > Your intuition is correct. >> > >> >> >> >> But at the same time, if there will be an error in the first example, >> >> it is IMHO a huge flaw with this RFC. :/ >> > >> > Flaw vs. design choice. This is one of the reason that this aspect, >> amongst others, has been very debated. >> >> But if it works this way, the strict mode isn't optional and users of a >> library NEED to care which mode the library uses? > > If library chose to use strict mode then the odds are it will take care o= f > passing right types to callbacks and interfaced methods. > > Saying that strict mode isn't optional is not true, I don't see why you h= ave > made this conclusion. Hello, I made that conclusion because in the first example, the library kinda forces strict mode rules on the caller, even if he doesn't want to use strict mode - this makes the interoperability of the two modes problematic. Also, the other possible outcome of the scenario (respecting the mode of the place where the callback is declared), is IMHO problematic as well, because it does not respect the strict mode of the place where it is called, making it inconsistent with how the dual mode RFC works in general. Regards Pavel Kouril