Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85185 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15110 invoked from network); 18 Mar 2015 12:13:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Mar 2015 12:13:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.41 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.218.41 mail-oi0-f41.google.com Received: from [209.85.218.41] ([209.85.218.41:35028] helo=mail-oi0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/B4-22462-1FB69055 for ; Wed, 18 Mar 2015 07:13:38 -0500 Received: by oiag65 with SMTP id g65so34220899oia.2 for ; Wed, 18 Mar 2015 05:13:34 -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; bh=PuWLUHjK3AlyHiY19Z4TBcnxX2XTFbD4T/wUpjGtcyQ=; b=dqbuPMUMBQMnFxLSil7tFz0hEPEBKAvEJAWPY24OVxCmpIb0sLacqmKHEvuh7sajAm erWW5v5OIgmA5hOBl+bw0+VCIJU160v1XwF0lcUFbyfGe6LZ3DHH2tFx1yj8lDGnd2mK r6Az7coR1U6eTjPtFV+tU6e/z7JPRf2i88AP2gKuU//BhUBtlWJT9fb//u+Us7h8hqyR Nb4ulBiYzK0a3ymWd8Ov1AIQErMId83Lhb16PV9Z9slND+MGUcZQrufeI0iHGNlzDRLw k/MXjbR55R5H8OQanG9NMr+1J0qd4sIBb21KGFTARK3lK3AhBr6VBxUAqqv6CY9HVsCb RqhA== MIME-Version: 1.0 X-Received: by 10.182.81.98 with SMTP id z2mr2416041obx.35.1426680814903; Wed, 18 Mar 2015 05:13:34 -0700 (PDT) Received: by 10.202.78.5 with HTTP; Wed, 18 Mar 2015 05:13:34 -0700 (PDT) Received: by 10.202.78.5 with HTTP; Wed, 18 Mar 2015 05:13:34 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Mar 2015 16:13:34 +0400 Message-ID: To: =?UTF-8?Q?Pavel_Kou=C5=99il?= Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7b2e48582e262e05118f03d2 Subject: Re: [PHP-DEV] [RFC][Accepted] Scalar Type Declarations V0.5 From: inefedor@gmail.com (Nikita Nefedov) --047d7b2e48582e262e05118f03d2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 of passing right types to callbacks and interfaced methods. Saying that strict mode isn't optional is not true, I don't see why you have made this conclusion. --047d7b2e48582e262e05118f03d2--