Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83790 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60188 invoked from network); 25 Feb 2015 15:06:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 15:06:36 -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.177 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.177 mail-lb0-f177.google.com Received: from [209.85.217.177] ([209.85.217.177:37943] helo=mail-lb0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/73-62407-AF4EDE45 for ; Wed, 25 Feb 2015 10:06:35 -0500 Received: by lbiz11 with SMTP id z11so4444976lbi.5 for ; Wed, 25 Feb 2015 07:06:32 -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=RHgLXFR4ohqZfMVat/aUZ4YX+6tfkQ93svjr+qPrKxA=; b=lXkH9FMzpB9kRolDjgYG2IZo2Mo/m5uD/iDmmeInj+iToOGk86OMu34bG1FzH5doPB s0k9UzzT7MuzSQ8+NEbBsgbvHIuzshh7UmMXZu3rCbWd2eMkgTCHby90Qxz4oVFPKSDB hw6mFROTAgloGg10PAjkPTfu9H5XLiuQot9T9ypBbQPktF3aPyX2JOhcwrJBz210RMaQ 9xL2czA4N8kTIogRSjv/8udAjZ4+CdgFWGkO+Q6Saba9dJbvL59N/3MMlKvt4fRGaPK/ P/5mrycdT9bTCneBaF8qkwMRQAI18vrCiSgjxkK29w5rxOL1AzVnicdFZu6/zhIcahNP UgJw== MIME-Version: 1.0 X-Received: by 10.152.88.49 with SMTP id bd17mr3122456lab.43.1424876792217; Wed, 25 Feb 2015 07:06:32 -0800 (PST) Received: by 10.25.43.9 with HTTP; Wed, 25 Feb 2015 07:06:31 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 10:06:31 -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 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.