Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83796 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69408 invoked from network); 25 Feb 2015 15:20:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:20:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.173 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.173 mail-vc0-f173.google.com Received: from [209.85.220.173] ([209.85.220.173:41438] helo=mail-vc0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/85-62407-048EDE45 for ; Wed, 25 Feb 2015 10:20:37 -0500 Received: by mail-vc0-f173.google.com with SMTP id hy4so1584176vcb.4 for ; Wed, 25 Feb 2015 07:20:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=7ABIMpz4vqStKir7o5UO7lWzOH94SvqkY6A8UWcsqiQ=; b=UdPaoxJGjhsHnWj9mWiTtr7HXV+H9Q4nej40xSjOdxQV9R58RDobbrwtRKntw7GLLp +hzgr6EjuND6C5LlRE0qKaAXlLqGLRTU6UPUnxeaduSE2wMFPa5dJ1tp+7Zq9eNsUgFu nwqvmy+U71sEueNwB4Wpi0brQdoQQ7+6OzHQFcLvL6W2T5i2xPNhzoYAu1z6v9tToXBc z3ZGxeoZEbm5ijuN7/HYUdjKW13LCcQD8ywv8T8C3I48FV3Y07Ipg1qQr23ZAfEx/hGd Zlp1WfoddMdYUOuGWr6eCZdC2sj/zrMflHIzsxuTdRWz7YkBMAMZVP4spbDAU4TqOGGg 7g0g== X-Gm-Message-State: ALoCoQld/yzC1gkKrao273y9ssNns5sd1G48l/ZceGQu6f8Vays3aGmq1Da+kB/ckMZIwNvqDwcZLWrr5TJcPZ1VoTzIz04V6mpvUm8x2Ypmxb4xJmfsbHBJCDJeAUDaIB4LnGY6Ho+UjMJLRAqgjRLXxKke9vFMlA== MIME-Version: 1.0 X-Received: by 10.52.162.72 with SMTP id xy8mr4448387vdb.12.1424877629764; Wed, 25 Feb 2015 07:20:29 -0800 (PST) Received: by 10.52.113.231 with HTTP; Wed, 25 Feb 2015 07:20:29 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 19:20:29 +0400 Message-ID: To: Anthony Ferrara Cc: Niktia Nefedov , PHP Internals Content-Type: multipart/alternative; boundary=089e01628326f88d37050feb2cba Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: dmitry@zend.com (Dmitry Stogov) --089e01628326f88d37050feb2cba Content-Type: text/plain; charset=UTF-8 On Wed, Feb 25, 2015 at 6:06 PM, Anthony Ferrara wrote: > Dmitry: > > On Wed, Feb 25, 2015 at 7:55 AM, Dmitry Stogov wrote: > > On Wed, Feb 25, 2015 at 2:42 PM, Niktia Nefedov > wrote: > > > >> On Wed, 25 Feb 2015 16:30:32 +0400, Dmitry Stogov > wrote: > >> > >> anyone may tell, what this will print without running :) > >>> > >>> main.php > >>> ======== > >>> >>> declare(strict_types=1) > >>> include "a.php"; > >>> include "b.php"; > >>> var_dump(foo("5")); > >>> ?> > >>> > >>> a.php > >>> ===== > >>> >>> declare(strict_types=0) > >>> function foo(string $a): string { > >>> bar($a); > >>> return $a; > >>> } > >>> ?> > >>> > >>> b.php > >>> ===== > >>> >>> declare(strict_types=1) > >>> function bar(int &$a) { > >>> var_dump($a); > >>> } > >>> ?> > >>> > >>> Thank. Dmitry. > >>> > >> > >> > >> Hi Dmitry, > >> > >> This will error out because $a in the scope of `foo` will be coerced to > >> int type when passed to bar by reference. > >> > > > > I think it'll work without errors and produce some explainable but weird > > output. I didn't run it myself yet. > > "Weird"? > > int(5) > string(1) "5" > > How is that weird? That's precisely what you asked it to do. > I just think that not allbody understand this and expect something different. Thanks. Dmitry. --089e01628326f88d37050feb2cba--