Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49192 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71584 invoked from network); 31 Jul 2010 14:17:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2010 14:17:25 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:34390] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 43/92-55997-A60345C4 for ; Sat, 31 Jul 2010 10:17:15 -0400 Received: by iwn36 with SMTP id 36so2586213iwn.29 for ; Sat, 31 Jul 2010 07:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; bh=5K0t0rIZr+S6nbaNf540l2lQFRghVILiQpcpG4gcqO8=; b=NIXLesNZOqa9hpAiuAxZAfFsKHXQH2QZ5kGo623uUoVXmME6rpyZv5tCmMzNbh7cWO yt0hCCQQHkArR1cfu5xnw3Ewu6IWiv190XSnm3xxTqabc3gVlmlA5pAWITfe5TvhvujA 03TYHeIEHLacxrl48IVHchsw+4OtJlMrT/q98= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=OFUjUvfNtFtvoJtr1oJSClLqW/whsuhJ8FRICJnnyPDRtR1UzPTnOMj8gXifzXOWQy wBKAjKHlf6vKLpTyrrzgWFqmK9FsA1sDKr1pjILEiMkyN5d35OPwPBw0RcU/CgRKWHeS 6PBdhKGXwK8HEEbvdXtkDPGTo4KWl5FXs3OAo= MIME-Version: 1.0 Received: by 10.231.36.69 with SMTP id s5mr3654939ibd.58.1280585831534; Sat, 31 Jul 2010 07:17:11 -0700 (PDT) Sender: tyra3l@gmail.com Received: by 10.231.11.141 with HTTP; Sat, 31 Jul 2010 07:17:11 -0700 (PDT) In-Reply-To: References: Date: Sat, 31 Jul 2010 16:17:11 +0200 X-Google-Sender-Auth: QVJ_IUONe43AXc2SxKyIq4JGx_4 Message-ID: To: Ignas Rudaitis Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Feature proposal: userland support for name qualification From: info@tyrael.hu (Ferenc Kovacs) On Sat, Jul 31, 2010 at 2:14 PM, Ignas Rudaitis wrote: > Hello php.internals, > > Here is a (hopefully) simple language feature I'd like to suggest: > > Now that PHP has support for namespaces and therefore makes it > possible to refer to classes, functions and constants by their shorter > unqualified aliases, it would be useful to extend this functionality > to string references to these classes/functions/constants as well. > Perhaps it wouldn't be as useful for constants, but class and function > names need to be used as string literals from time to time, so given > that a statement like "use Foo\Bar\Baz" is present, having a special > syntax for retrieving the fully qualified name as a string, like > Baz::__CLASS__, qualify(Baz) or use(Baz) would save numerous > keystrokes, eliminate possible typos and make refactoring (renaming) > easier. > > The use cases that come to my mind are class names in exception > messages, in DI container setup code, also things like Doctrine's > $entityManager->getRepository('Application\Entities\Message') and > callable function name strings. > > Of course, if it's actually problematic to implement this, that's > fine, just let me know. > > Thanks. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi. I think that this could be a good feature. You can get the qualified name with get_class() if you have an instant, or with __CLASS__ in your class methods, but you can't explicitly convert an unqualified name into qualified. However this wasn't a big problem for me, because every reference is used as a fully qualified name, so I never had to convert between them. But this could be a good addition to the namespace features. Tyrael