Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85041 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98197 invoked from network); 16 Mar 2015 12:24:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 12:24:23 -0000 Authentication-Results: pb1.pair.com header.from=leedavis81@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leedavis81@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.175 as permitted sender) X-PHP-List-Original-Sender: leedavis81@gmail.com X-Host-Fingerprint: 209.85.213.175 mail-ig0-f175.google.com Received: from [209.85.213.175] ([209.85.213.175:37908] helo=mail-ig0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/D5-03331-57BC6055 for ; Mon, 16 Mar 2015 07:24:23 -0500 Received: by igbue6 with SMTP id ue6so39558445igb.1 for ; Mon, 16 Mar 2015 05:24:19 -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=rpHr3/Ixhq1F3a6bdSeDcTQsOfMSItCYFL7ugtFd4Ec=; b=TmUcZ+JE+YoPm2PPpTjv7ZglkS4UDCSSS7OdBsNEyPRbSMZH5okOmy5UFI8PfvbZL8 XB6aS7kCpz2ORwgT0s7wczZMeOXSDEwGU8mWkHSa6VnixrUYlw5m7+lKPHGcAMrHhm5g mIidTaRKas7FRWfWRju3zsnyypNLbxJZRz+QlwCcbmr2gD6oEPjQ3iOIeGqwObFdWJIa ueDUEuCI5+R1pgwDodGFW+QjX52ZXU7uKGhQSFCCUNF7/BuXY/OcrpDn30flhqri2AWm G/pbG69Qa3RUZiVvS3RINCSqfb3V+4RUkT1K4xZa6mREGFNHTRlNkYCRgt5NBQnE9cF6 +7Ug== MIME-Version: 1.0 X-Received: by 10.42.210.148 with SMTP id gk20mr78181050icb.81.1426508659529; Mon, 16 Mar 2015 05:24:19 -0700 (PDT) Received: by 10.36.92.202 with HTTP; Mon, 16 Mar 2015 05:24:19 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Mar 2015 12:24:19 +0000 Message-ID: To: Yasuo Ohgaki Cc: Derick Rethans , Xinchen Hui , Pierre Joye , PHP internals Content-Type: multipart/alternative; boundary=20cf303dd668eb9eab051166ed8b Subject: Re: [PHP-DEV] About declare(strict_types = 1) From: leedavis81@gmail.com (Lee Davis) --20cf303dd668eb9eab051166ed8b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Mar 16, 2015 at 11:33 AM, Yasuo Ohgaki wrote: > Hi Derick, > > On Mon, Mar 16, 2015 at 8:18 PM, Derick Rethans wrote: > > > On Mon, 16 Mar 2015, Xinchen Hui wrote: > > > > > On Mon, Mar 16, 2015 at 5:00 PM, Pierre Joye > > wrote: > > > > > > > > On Mar 16, 2015 4:29 PM, "Xinchen Hui" wrote: > > > >> > > > >> that means, I need to add a lots of (int) while I try to call= a > > > >> function in a library which is not written by myself. > > > >> > > > >> is that right? > > > > > > > > You got the answer but one thing bothers me a lot right now. > > > > > > > > How did you vote against this rfc while missing the core point of i= t > > (after > > > > actually having a strict mode)? > > > > > as I said, > > > " > > > acutaly, I believe in most applications, they will still keep this > off.. > > > > > > so why we introduce such thing? > > > " > > > I don't like strict_types at all.. > > > > To be frank, I don't think "I don't like this" is a terribly good reaso= n > > to vote against (or for something). What is important is how many peopl= e > > would actually benefit from a feature, without it causing issues for > > others. I am certainly no fan of the "declare" *syntax*, but I do know, > > from talking at conferences that many many developers would like to see > > scalar type hints in some way =E2=80=94 both weak (mode 1 of the STHv5 = RFC), and > > strict (mode 2). It even caters for people that don't want to use them > > at all, as they can simply not use them. I also know, that without a > > dual mode, it seems very unlikely for scalar type hints to make it > > into PHP 7, and I don't think that is what users want. As this is our > > *best* bet, I can only vote "yes". > > > Are you sure on your bet? > > lib.php: > declare(strict_types =3D 1); > function foo(int $a) { > // no function call here > } > ?> > The declare here does just nothing. > > a.php: > require "lib.php"; > foo("123"); // will work > ?> > > b.php: > declare(strict_types =3D 1); > require "lib.php"; > foo("123"); // will give an error > ?> > > This behavior is unacceptable. > Caller (a.php, b.php) must satisfy lib.php expectation to make lib.php > work as it should. Otherwise, all kinds of unexpected for lib.php and it'= s > users may happen. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > Hi Yasuo, The expectation here has been made by the caller (i.e. they=E2=80=99ve p= ut declare strict=3D1 in their file). It=E2=80=99s not an expectation of the l= ibrary. The library get=E2=80=99s the types it wants (whether they're coerced or no= t) regardless of what the caller does, and the caller get=E2=80=99s the benefi= t of being able to assure all their parameter types are correct. /@leedavis81 --20cf303dd668eb9eab051166ed8b--