Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83801 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77273 invoked from network); 25 Feb 2015 15:37:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:37:28 -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.179 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.179 mail-vc0-f179.google.com Received: from [209.85.220.179] ([209.85.220.179:47276] helo=mail-vc0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/37-62407-73CEDE45 for ; Wed, 25 Feb 2015 10:37:28 -0500 Received: by mail-vc0-f179.google.com with SMTP id hy4so1602589vcb.10 for ; Wed, 25 Feb 2015 07:37:25 -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=Hm3Tb6kNxpR/dNhY2KEANOnjSUkzrlk9apXrVeTC4fk=; b=lb4Iv4dylPyopDfzhLuA+5PAH+GQREp2SoHw/XTGZoCm50kZGf0fsP/4ZznuTNss08 NpHb6GJ90fdd4OH2Mzjma8Z4Tb7zL9PA+RHzDTjJuJXUriOT0QBfbGPlX7u4Z57OKHUv EMNRHnKlBa7cB/gM7Px/jn+auKiqhoD85nTzw5UtcpdTGtwG1O3+X+QkjsKGyVlB0asC UwLxsyqX2ulf40I3J2uA4t9HdNjBjUEoKCoYsHUpz8HJ3Y4IVB3GMb8pceGSTD3fVPJb IcgGnrbHgAZSCNgvcpGfZc4WKod+xr4Qg31kGS27/eo5oFW8lNnnvQMlHlBeQiEBJ+n+ BQUQ== X-Gm-Message-State: ALoCoQlYHokE1+rWe+IB18ltKSwpTPuLL+rg1Yl9X8qCH6W/a8Aiz/ncmXufufUBppNIQqRn8TlxNCAN9Oz7Q3m4GTrZolfJIt69tDSOZhtbSj6K6FU5eRoTmmPYN58A711IZd1SuKoFbtd3DToG7jSOGljJmtPzSw== MIME-Version: 1.0 X-Received: by 10.52.25.11 with SMTP id y11mr4364506vdf.51.1424878644958; Wed, 25 Feb 2015 07:37:24 -0800 (PST) Received: by 10.52.113.231 with HTTP; Wed, 25 Feb 2015 07:37:24 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 19:37:24 +0400 Message-ID: To: Anthony Ferrara Cc: Niktia Nefedov , PHP Internals Content-Type: multipart/alternative; boundary=001a1133e5f27b2e59050feb69da Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: dmitry@zend.com (Dmitry Stogov) --001a1133e5f27b2e59050feb69da Content-Type: text/plain; charset=UTF-8 On Wed, Feb 25, 2015 at 6:24 PM, Anthony Ferrara wrote: > Dmitry > > On Wed, Feb 25, 2015 at 10:20 AM, Dmitry Stogov wrote: > > > > > > 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. > > Looking at that code, even not knowing this RFC and the details of the > implementation, what would you expect to be different about it? > I expected the same, especially because I read the code. > Now, having read the RFC and played with the patch (even though you > admitted that you didn't), what would you expect to be different? > You already saw, at least one who was in time to make mistake. I was expecting this :) Thanks. Dmitry. > > Anthony > --001a1133e5f27b2e59050feb69da--