Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82493 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75134 invoked from network); 11 Feb 2015 21:03:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Feb 2015 21:03:02 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:42100] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/31-02515-483CBD45 for ; Wed, 11 Feb 2015 16:03:01 -0500 Received: by mail-wg0-f54.google.com with SMTP id y19so6003659wgg.13 for ; Wed, 11 Feb 2015 13:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type:subject:from:date:to:cc :message-id; bh=xS8kDCigCQpmQFyDAz/RT1v+5chmT39HBZmJa4K0tjc=; b=b0DN2XCtTFjslH5yf4gqzaUANxhd2ljnaBsey67SoaRcEXUcHwyAbo5ZSrlZ6XbTvH nXqdM1zDt32+QMFOPH2ph96aw7+d6NjTHX1lbV7dA3Tu9Nypfze9PLhScbqzt5ujRG6H cYn/qGdwpoFG9tCnNmB1ptszMeCa8GPEnYNa3vqwcAzrkDN3eq5uSLWL6kgJMSDYgI3J erSimtksVfwu0NkFVKX8tdp5AcZxOrHlgqIuZo4LCapddImk3LX7XdiLs1fSs/vucdlB dQnzxQq5qImQrqcIbKggO4csIwpnDoDGGQNcuS8JDNGjeTcQ5GhZJG1KuIQ6xW/Gtiwh d3Eg== X-Received: by 10.180.73.171 with SMTP id m11mr6498111wiv.21.1423688577370; Wed, 11 Feb 2015 13:02:57 -0800 (PST) Received: from [192.168.0.3] (cpc68956-brig15-2-0-cust215.3-3.cable.virginm.net. [82.6.24.216]) by mx.google.com with ESMTPSA id g10sm24857091wic.7.2015.02.11.13.02.56 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Feb 2015 13:02:56 -0800 (PST) User-Agent: K-9 Mail for Android In-Reply-To: <54DAF884.7000508@lerdorf.com> References: <8703B53E-2C4A-4AC6-95C4-D4F19C6D5221@ajf.me> <54DAF884.7000508@lerdorf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Date: Wed, 11 Feb 2015 21:02:51 +0000 To: Rasmus Lerdorf ,Andrea Faulds CC: PHP Internals Message-ID: <999E2554-B834-419F-98E1-C69A0DBDAE20@gmail.com> Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: rowan.collins@gmail.com (Rowan Collins) On 11 February 2015 06:36:52 GMT, Rasmus Lerdorf wrote: > And in Drupal8 *without turning on strict*: > > use Drupal\Component\Utility\String; > > it dies with: "Fatal error: "string" cannot be used as a class name in >/var/www/drupal/core/includes/bootstrap.inc on line 11" > > That String class is everywhere in Drupal. They are going to have a > fun time with that. See >https://gist.githubusercontent.com/anonymous/d9252deeeb2aae1a5af5/raw/053155130d22551b1404d0a9b94e27424544b6d1/gistfile1 That could potentially be avoided if scalar types were reserved as some kind of pseudo-class rather than just keywords, because then they would follow namespace resolution rules. Theoretically, you could still have a class "Drupal\Component\Utility\String", and "\string" would be available as a scalar typehint while you were in that namespace. I'm guessing it's not as simple as that, because the compiler needs to distinguish between scalar and classname typehints, but doesn't know what classes exist. In which case, perhaps "string" as a typehint could always mean "\string", and if you want to typehint the class you should always use "foo\string"? Or you could ban "string" as a typehint, and require people to type "\string". Either seems a little bit magic, though. Theoretically, I guess they ought to be "php\string" etc, which would accomplish the goal but make them rather unwieldy. It might be worth considering, though, given we know the situation's not just hypothetical. Regards, -- Rowan Collins [IMSoP]