Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85084 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3193 invoked from network); 16 Mar 2015 20:03:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 20:03:56 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.176 as permitted sender) X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.213.176 mail-ig0-f176.google.com Received: from [209.85.213.176] ([209.85.213.176:35607] helo=mail-ig0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/5A-34940-B2737055 for ; Mon, 16 Mar 2015 15:03:55 -0500 Received: by igcau2 with SMTP id au2so15124190igc.0 for ; Mon, 16 Mar 2015 13:03:52 -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=hsuOcdudQvYXEz7/QEUZm5obPMpLv5U2hSix2Y6APTY=; b=mDeBpbCZy4scit6J33YWkQSTGTLIcWMc75p+77KT5ytiRrBgvkuyWiXdYu8eZ7VZ3+ 2CsE3FgGdklB8/JOBLQg6nvOAvH6dgjIcifx/ymRPRgPasCh7mcGD1WVCPns1zhR1C+2 gdR/XHirMQq4U3UymHe+buZavF04GLX2mwI4GNQHn4mUkzs2c9nxGU5K7Fl0LbESM7m3 FRUgFYFSaOnD/3w/MQYuSFmp6vEPDbw8qgB60jO8u4p9Mzc3UeJivn7kixP74TQAfxE4 3RRasU4JJkue4+cDh0Lqq0HfR7rmgTjyF6dTigiphkm9pOU6nWQ0gy16A/TaMju1+6Ec 93/Q== MIME-Version: 1.0 X-Received: by 10.42.62.140 with SMTP id y12mr79537618ich.82.1426536231954; Mon, 16 Mar 2015 13:03:51 -0700 (PDT) Received: by 10.64.110.194 with HTTP; Mon, 16 Mar 2015 13:03:51 -0700 (PDT) In-Reply-To: References: <55066F07.80308@birkholz.biz> Date: Mon, 16 Mar 2015 15:03:51 -0500 Message-ID: To: Yasuo Ohgaki Cc: Dennis Birkholz , "internals@lists.php.net >> 'PHP Internals'" Content-Type: multipart/alternative; boundary=90e6ba614e705d909c05116d593b Subject: Re: [PHP-DEV] About declare(strict_types = 1) From: pencap@gmail.com (Mike Willbanks) --90e6ba614e705d909c05116d593b Content-Type: text/plain; charset=UTF-8 On Mon, Mar 16, 2015 at 2:12 PM, Yasuo Ohgaki wrote: > Hi all, > > On Mon, Mar 16, 2015 at 2:49 PM, Dennis Birkholz > wrote: > > > Am 16.03.2015 um 06:28 schrieb Xinchen Hui: > > > lib.php > > > > > declare(strict_types = 1); > > > function add(int $a, int $b) { > > > } > > > > > > > > add($_GET['a'], $_GET['b']); > > > > > > 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. > > > > that is not right and has been discussed a thousand times over. > > The declare changes the rules only for function calls in the file it is > > declared in. > > > > so: > > lib.php: > > > declare(strict_types = 1); > > function foo(int $a) { > > // no function call here > > } > > ?> > > The declare here does just nothing. > > > > > require "lib.php"; > > foo("123"); // will work > > ?> > > > > > declare(strict_types = 1); > > require "lib.php"; > > foo("123"); // will give an error > > ?> > > > > If this kind of behavior is allowed, why "strict mode" is strict? It's not > strict at all if mode could be overridden. > > "strict_mode" is just controlling errors, then it should be handled as > error E_WARNING/E_TYPE or whatever. > > Even if what it controlling is error that can be overridden by caller, yet > calling it "strict" is not correct. Proper name would be something > like "raise_type_error". > > Let see how it looks if "strict_types" is renamed to "raise_type_error" > > declare(raise_type_error = 1); > function foo(int $a) { > // no function call here > } > ?> > The declare here does just nothing. > > require "lib.php"; > foo("123"); // will work > ?> > > declare(raise_type_error = 1); > require "lib.php"; > foo("123"); // will give an error > ?> > > Is everyone feel OK with this?? > That seems far more odd in my opinion. I vastly prefer the first. --90e6ba614e705d909c05116d593b--