Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83797 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70969 invoked from network); 25 Feb 2015 15:24:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:24:28 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.182 mail-lb0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:36544] helo=mail-lb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 44/E5-62407-929EDE45 for ; Wed, 25 Feb 2015 10:24:27 -0500 Received: by lbvp9 with SMTP id p9so4573212lbv.3 for ; Wed, 25 Feb 2015 07:24:21 -0800 (PST) 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=qlGjOHv1eRaoz1U3sCLBdsPDXiyQ10/cQ1+HBBTAp5k=; b=QzEF8JfQbwsM0RHsOu2Ocz0IG+AlphzeUbQ7s0vTMdSy9fJC6N8/6yKs4bzr7wvXFh rxj9/3CNkrbMxP6DTm3s3fF4raz4w/p1PblIqNm4fyi5MZV/rpIpHawSfaQ2VoqWzP4p d6oKvqwu/Rh/P43mAvy0BHTxvvNZ7RY1TBLwMd+L1MF3a5MDc3MEmWpwO/H59BMWcfQG kz9q8sT79i5yj6kisBgxAHQ7RKhjhQ43JOi7lCb4bWcradAK7ySEZ/OajGgCqywqxjWN Fx4XONzxTvq4Uo/DPLeExGKMOV8c6DnbnNfgPjJlDSoaoY9+vEG+vEqQIHOSIMVZM1Zb 05Yg== MIME-Version: 1.0 X-Received: by 10.112.139.136 with SMTP id qy8mr3322710lbb.38.1424877861622; Wed, 25 Feb 2015 07:24:21 -0800 (PST) Received: by 10.25.43.9 with HTTP; Wed, 25 Feb 2015 07:24:21 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 10:24:21 -0500 Message-ID: To: Dmitry Stogov Cc: Niktia Nefedov , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: ircmaxell@gmail.com (Anthony Ferrara) 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? 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? Anthony