Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42757 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45175 invoked from network); 21 Jan 2009 21:41:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Jan 2009 21:41:20 -0000 Authentication-Results: pb1.pair.com header.from=kkooporation@googlemail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=kkooporation@googlemail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.200.174 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: kkooporation@googlemail.com X-Host-Fingerprint: 209.85.200.174 wf-out-1314.google.com Received: from [209.85.200.174] ([209.85.200.174:36105] helo=wf-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 33/10-19181-E7697794 for ; Wed, 21 Jan 2009 16:41:19 -0500 Received: by wf-out-1314.google.com with SMTP id 26so3956494wfd.26 for ; Wed, 21 Jan 2009 13:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=ubfTJDFIg4/BroPP9et7jMRavp7DnoRg7y71VxWCAxY=; b=IX3G5J/+/Au7SyevhYTnMDtTiaRuCjaQjZkgHexmdv68mzharhP1aksba58Z8JE7Pu LPVIereCqEbIdDyNgPzbfA7akd1iddPyQCyYRU9zKZ7N2m0VujJiOu2usSNkUy0Lqceb LhAaxpOmH6/Lnly0SiCs5I8s1j1WNj1fPaBOo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.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=KtIbQEvqumzx9G8N0k1MlnSzZyzC345BJvO9lAtKd2LDQuDbb2hphmjq85JkEyjqmS RADxa8wPM9BxK6V5g5KakwFj5IdJ3+6xGQiLBPXOM2C73eWrD/LMMhEuiVhBWh+fjHgW A5njr4XsofJqO6cAf/van7DbWVhPnXsLrQ2CQ= MIME-Version: 1.0 Sender: kkooporation@googlemail.com Received: by 10.142.125.9 with SMTP id x9mr457446wfc.236.1232574076059; Wed, 21 Jan 2009 13:41:16 -0800 (PST) In-Reply-To: <49778E0A.5010806@grudl.com> References: <49778E0A.5010806@grudl.com> Date: Wed, 21 Jan 2009 22:41:16 +0100 X-Google-Sender-Auth: 9a784bdd6e6a1ea9 Message-ID: To: David Grudl Cc: PHP internals Content-Type: multipart/alternative; boundary=000e0cd228b8f681b9046105036f Subject: Re: [PHP-DEV] Enhanced __CLASS__ constant From: kureal@kkooporation.de (Kenan R Sulayman) --000e0cd228b8f681b9046105036f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hey! First of all: the idea is very good. Criticism: Again, that's a new Syntax "feature"; May we deploy this into next releases of PHP? Thanks! -- (c) Kenan Sulayman Freelance Designer and Programmer Life's Live Poetry 2009/1/21 David Grudl > Especially in namespaced code it should be very useful to have "something" > returning fully qualified name as string. It can be operator, but I think > introducing new keyword is bad way, or it can be realized using well known > magic constant in new context: > > Example: > > function factory($class) > { > return new $class; > } > > $obj = factory('MyClass'); // returns object MyClass > $obj = factory(MyClass::__CLASS__); // returns again object MyClass, code > is little bit more selfexplaining > > > But big advantages are in namespaced code (especially when you refactor a > code): > > namespace Foo; > use Other\Bar; > > $obj = factory('MyClass'); // ERROR - returns object \MyClass, must be > refactored to: > $obj = factory(__NAMESPACE__ . '\\MyClass'); // very very ugly! :-( > $obj = factory('Other\Bar'); // use statement must be duplicated here :-( > > // with magic contant: > $obj = factory(MyClass::__CLASS__); // returns object Foo\MyClass, very > understandable :-) > $obj = factory(Bar::__CLASS__); // returns object Other\Bar, as use > statement declares :-) > > David Grudl > > > > > > > > > > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000e0cd228b8f681b9046105036f--