Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85082 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96447 invoked from network); 16 Mar 2015 19:13:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Mar 2015 19:13:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:35433] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/89-34940-E4B27055 for ; Mon, 16 Mar 2015 14:13:19 -0500 Received: by oiag65 with SMTP id g65so46560239oia.2 for ; Mon, 16 Mar 2015 12:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=GTOdCqkosGqYic7auSkbKU7PCtyuySBXndelD5MDLWo=; b=p1/bl3zUMKe25CxOudZZCwiamulzFtICQ0VjZPfG9CDx7kybx41uWU1Gg1kD6zsG71 fTPOo5uh6nLCqRvl66+5uS/C3Xrz0w7VLK24nY4ghDoPJBoxvZao3ncbs1rePfZzrotr +ehGojG6dHC9/IE47asaeFRPFawPHdCOknSodZrY1J2slfAo3bF3OnEiKOyUHkcx11Eg gyL0P2uSLY8pNuQ+PqYADT5JK6AdYcFc8QHeWPlkPtzudY6KXsUNW/oOint/KtzNTZkh Wg9/GcMvK0To1z3eJbfZ6wdv1fBy7ahVofaXQtnvA+bHpkSkQSN3guUpcldQ5R1sdjCM yi2Q== X-Received: by 10.182.128.199 with SMTP id nq7mr27045046obb.47.1426533195771; Mon, 16 Mar 2015 12:13:15 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.202.58.2 with HTTP; Mon, 16 Mar 2015 12:12:35 -0700 (PDT) In-Reply-To: <55066F07.80308@birkholz.biz> References: <55066F07.80308@birkholz.biz> Date: Tue, 17 Mar 2015 04:12:35 +0900 X-Google-Sender-Auth: 07aycxtdS8k62eYqkwGU7RVzK3w Message-ID: To: Dennis Birkholz Cc: "internals@lists.php.net >> 'PHP Internals'" Content-Type: multipart/alternative; boundary=089e01537e7664f5ce05116ca48b Subject: Re: [PHP-DEV] About declare(strict_types = 1) From: yohgaki@ohgaki.net (Yasuo Ohgaki) --089e01537e7664f5ce05116ca48b Content-Type: text/plain; charset=UTF-8 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" The declare here does just nothing. Is everyone feel OK with this?? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --089e01537e7664f5ce05116ca48b--