Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83780 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37845 invoked from network); 25 Feb 2015 12:56:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 12:56:02 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.175 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.175 mail-vc0-f175.google.com Received: from [209.85.220.175] ([209.85.220.175:38230] helo=mail-vc0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/9F-62407-066CDE45 for ; Wed, 25 Feb 2015 07:56:01 -0500 Received: by mail-vc0-f175.google.com with SMTP id hq12so1236793vcb.6 for ; Wed, 25 Feb 2015 04:55:58 -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=w3ph5iaWG3Mmdt4cp4QZzdQGcowPeLMVcEHteS/nlmE=; b=fK3Op+psQi3ywnM4fQQGaMpYTQNV/eihQkWhSEFxuBdRZdkrwHsvf8Qd1+/TwejRCI KK8/qkDn1+gjtvWOmm141GGY9qdV1cLcCWGkd44l4jYjW9O4T+d/tjosHyDCn6kD9ugE bPsqZYKUhPS356XUCyqfmumHOx5iFv5X7NwJ+1oV8ebDjqV5v+8FzT3zYh4CP8IrhV1I xGdpHkjqwcQOSkggZX8FNYvKTZk+S1unmS/grsPfcRZnQ9uwWaon19lj8KNQaO9gAdNG tVer96S3dnKWAOihQiKVZXWr7XGDhZOV53RV1SB2amnz2Nn+dt5PjptHfA9pcZrjiz0j J8Bg== X-Gm-Message-State: ALoCoQkYUTE5AomuSy+vKJQLizXw1odfVbMmWUmjc4Jtd/q38aduH6WfoEwuGiw6qyY4+cks0HiHdq9sAozQ/8/TIVs5Aw6TUt/pjEbBLS259RuN99WcsUvfQBpv6kmfAIpq6aSh7AGbk/3flJd3voWAYWEmguwKTA== MIME-Version: 1.0 X-Received: by 10.52.99.230 with SMTP id et6mr3757547vdb.65.1424868958118; Wed, 25 Feb 2015 04:55:58 -0800 (PST) Received: by 10.52.113.231 with HTTP; Wed, 25 Feb 2015 04:55:57 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 16:55:57 +0400 Message-ID: To: Niktia Nefedov Cc: PHP Internals Content-Type: multipart/alternative; boundary=20cf3071c7c019ba45050fe92842 Subject: Re: [PHP-DEV] Re: [RFC-Discuss] Scalar Type Declarations v0.5 From: dmitry@zend.com (Dmitry Stogov) --20cf3071c7c019ba45050fe92842 Content-Type: text/plain; charset=UTF-8 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. Thanks. Dmitry. > > 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. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --20cf3071c7c019ba45050fe92842--