Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92321 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96022 invoked from network); 14 Apr 2016 23:40:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Apr 2016 23:40:59 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.66 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.66 mail-lf0-f66.google.com Received: from [209.85.215.66] ([209.85.215.66:32778] helo=mail-lf0-f66.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/25-64966-98A20175 for ; Thu, 14 Apr 2016 19:40:58 -0400 Received: by mail-lf0-f66.google.com with SMTP id p64so14416681lfg.0 for ; Thu, 14 Apr 2016 16:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=/Bh2bx4e9Tzq7U/JuhcJ4MFDyPLrZmegC+KRohqQfgw=; b=rFDL4MDVJ5InOlcDbK2e4fCoxtBsZD1nr0bDx93KBrz9jJj4NwMHhcttgwBu0EPutN UJbCVQ4kJO7N/PLV5T8ojwoCKjqBt8nNnByfr+EEcA8Wy9Wj4TzxANUtZZR3sFIxbGMC II9m17uZyVcfFjKj6Ij3sIMddvdGLXe+i4dNJs0991QiCAmwuKhpLdwzSv0NfBvzuNVa wMctHZ8Om9UKXzn34Lx78HgaCV6H9m5/5XRIuCU0RfK5b5Ynpsf4VCV0VBSUs4VtNrfZ lH7pIQE+1+FXfqhOsRYOUpDVJgpzpJ/hTrwJX6sns2mmJZkkSQImKhKRvWNahFa7cuH0 DMdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=/Bh2bx4e9Tzq7U/JuhcJ4MFDyPLrZmegC+KRohqQfgw=; b=LDoVLuC/pZQ2VT3t3yVhMuRwYPqJXnNhvWml76R8LTlSNkmR6U5pz1wff3OeNxjskX 29FrspbGqElcmmRfvOTZuwgpXoDNBCZ5c5w+nfuUseUN1cGWzbDd3LmH2sPCBmcul+I/ gn5d+VXR62gXrr5WNqhVpzElhe36awMd0GtDlyYJmAscIAmRT/RUiYfmz7OYzwT+gw4g 9Uqb+M3ddQB1WiKjW2GV9Q7Jh6K/jR4jtiSQn0pKtV3l64oqAcKseigU4GOS6VRIj/DD CZWpIgm1x+UIPpMc8fExgCxmAMeb59t2bd9gdOLRILRP2Ss66alXONuAFy9g/MoWY1mC gcaQ== X-Gm-Message-State: AOPr4FWhHADGvrkb8eXE0ia5hR6XqoTS2Kp8bCx/mBbAl/BghezscmTrN46/cnjnAChz+JcgESPhEYmkm5qxJA== MIME-Version: 1.0 X-Received: by 10.25.86.144 with SMTP id k138mr5921247lfb.6.1460677254632; Thu, 14 Apr 2016 16:40:54 -0700 (PDT) Sender: php@golemon.com Received: by 10.112.19.74 with HTTP; Thu, 14 Apr 2016 16:40:54 -0700 (PDT) X-Originating-IP: [107.198.91.68] In-Reply-To: References: Date: Thu, 14 Apr 2016 16:40:54 -0700 X-Google-Sender-Auth: JnRJS_JKOHhVFVkGhzcQelGP-ps Message-ID: To: Davey Shafik Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Interpolation using ${} syntax with spaces inside the braces From: pollita@php.net (Sara Golemon) On Thu, Apr 14, 2016 at 3:37 AM, Davey Shafik wrote: > Whitespace inside of { } should not matter, the contents should be evaluated > as an expression and it's results used to determine the variable name, so > ${great} should also be $my as in the other cases. > Right. Which is why I'm conflicted on bug/not-bug/different-bug. IMO, the label inside ${...} should either always be a variable name (like HHVM handles it), or always be an expression. What we have is "It's always an expression except in the one specific case of it being a valid variable name, in which case that takes precedence. Since the versions containing spaces aren't valid variable names, they fall back on the more general expression handling. So I'd be inclined to say "That exception to the rule is the problem", except that this is variable interpolation behavior that goes ALL THE WAY BACK, and I wouldn't break BC for the world. So the question becomes: What's the right move going forward. My inclination would be to either: A: Ignore surrounding whitespace within the ${...} expression. Essentially, adopt HHVM's output for these examples. B: Throw an error on surrounding whitespace. This will make discovering timebombs like these in existing code easier to catch. In either case, if the programmer actually did want the constant->variable double-interpolation, that could be easily achieved via "${(foo)}" which disambiguated foo as a variable name from foo as an expression. -Sara > Is this related to the use of quotes around string array keys inside > strings? > > e.g. "$foo[great]" does not evaluate to $foo['my'] but to $foo['great']. > I don't think so... I have a feeling that's yet another weird oddity to PHP parsing that's waiting to bite us in new and surprising ways. -Sara