Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80158 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40407 invoked from network); 4 Jan 2015 19:11:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2015 19:11:37 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.207 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.207 imap2-2.ox.privateemail.com Received: from [192.64.116.207] ([192.64.116.207:58072] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/D4-02442-86099A45 for ; Sun, 04 Jan 2015 14:11:37 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id DD1B38C007D; Sun, 4 Jan 2015 14:11:33 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dn21IC428Ujn; Sun, 4 Jan 2015 14:11:33 -0500 (EST) Received: from [192.168.0.13] (unknown [94.13.96.117]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 8AB628C0009; Sun, 4 Jan 2015 14:11:32 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Sun, 4 Jan 2015 19:11:00 +0000 Cc: Derick Rethans , Stanislav Malyshev , PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <53DCFD59-4980-4FDE-9387-AF8D0E7A6E71@ajf.me> References: <41D5BB0B-73AF-488E-968D-90B2878E3178@ajf.me> <54A466CB.9020400@gmail.com> To: "Sebastian B.-Hagensen" X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Scalar Type Hints From: ajf@ajf.me (Andrea Faulds) Hey Sebastian, > On 4 Jan 2015, at 19:02, Sebastian B.-Hagensen = wrote: >=20 > It might add some value to forbid importing of unaliased type named > classes via use, so that no ambiguous type annotation exists. > Example: >=20 > use My\Lib\string as UserString; // fine, no error > use My\Lib\int; // Compile error: Forbidden to import scalar type. Use > `as` to create an alias That=E2=80=99s something that was actually on my todo list. No point in = forbidding class names if you can get around it with `use`. Once I do this in the patch I=E2=80=99ll update the RFC to say as much. > Most libraries should be able to resolve such issues in a minor > release to stay compatible with PHP 7. If a user doesn't use PHP 7 he > won't be affected as the old import still works and the name of the > class (if namespaced) hasn't changed, if he switches to PHP7 the > updates can probably be automated. Yes, this is possible. You could just rename the class to something = that=E2=80=99s OK in both PHP 5 and 7 (IntClass, e.g.), then add a = conditional class_alias() for PHP 5. Actually, I=E2=80=99d need to update class_alias() as well. Hmm. Maybe I = should make some sort of internal is_class_name_permitted() function. > Namespaced classes can still be named whatever they want as the > following(typehint an alias of the own class, using FQN) is already > valid and the signature of the method would not change(no major > release of a library required).: >=20 > namspace abc; > use abc\int as MyInt; >=20 > class int { function a(MyInt $a, \abc\int $b) ;} I don=E2=80=99t like the idea of allowing these within namespaces, = because relative uses would still be broken. Better to just force people = to fix their class names. Thanks. -- Andrea Faulds http://ajf.me/