Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83777 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29922 invoked from network); 25 Feb 2015 12:43:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 12:43:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=inefedor@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=inefedor@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: inefedor@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:44231] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/ED-62407-E63CDE45 for ; Wed, 25 Feb 2015 07:43:27 -0500 Received: by lbiz12 with SMTP id z12so3471774lbi.11 for ; Wed, 25 Feb 2015 04:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:to:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=VaBcMSnfnsxnPwtfzi4AGV+E87eaUeY4JEI8QLnWQYk=; b=snRgbdunxKA/duO2aehXtF9LuoAu0a5KtOCNxg5ar88N3fyyezuz50DWPtRqoW4NIX xUHGoa7n+x/XaaLRpiD3zGndSyVkyKf1izi/MPeKRj2J9eqoC1XE55v5kJh7aJPUNqUm xLqVpArM276yVC5FAy48QTxGioieMDNJJjCYSM84TSYSpTdO/760AGGCdN8t6bWhvaYa kPtzYDZ7VF5Q8YlDGGqyfHDKUAZLYNc7xSkrLqaaL7bL4aSTjfLaRnAasWSLdiGWpjkY g9KQYgs4d+Tm9Argb0Iw0RGp3zYzYnmEnolDfA0G8DwMjwEscDo1gTPCDe64ZbzqLTuc ij+g== X-Received: by 10.112.90.193 with SMTP id by1mr2488949lbb.113.1424868203627; Wed, 25 Feb 2015 04:43:23 -0800 (PST) Received: from nikita-hp-elitebook-750-g1 (broadband-37-110-139-150.nationalcablenetworks.ru. [37.110.139.150]) by mx.google.com with ESMTPSA id pq7sm8264867lbc.17.2015.02.25.04.43.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 04:43:22 -0800 (PST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: Date: Wed, 25 Feb 2015 15:42:11 +0400 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: User-Agent: Opera Mail/12.16 (Linux) Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: inefedor@gmail.com ("Niktia Nefedov") 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. References are a problem for weak-only types as well (even more so I would say, because in a lot of cases they would continue working truncated or changed). Happily there are not lots of post-php5 code that uses references here and there, but that would be good to add the point about them to both RFCs (and in documentation in future) just so that users would be aware of that.