Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42775 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54154 invoked from network); 22 Jan 2009 13:11:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2009 13:11:05 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.232 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.198.232 rv-out-0506.google.com Received: from [209.85.198.232] ([209.85.198.232:22118] helo=rv-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/D7-15341-56078794 for ; Thu, 22 Jan 2009 08:11:02 -0500 Received: by rv-out-0506.google.com with SMTP id g37so4222741rvb.23 for ; Thu, 22 Jan 2009 05:10:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=+jvfT6SEde/GR1Qm0o8o4Cg1vPRNqrb0KQxi63zAqjo=; b=XYBJErJD6rluDHl+wUt91yq2/vQVP71y5/rLhzSbwPXFWy9o7KXfC/rZNzNFRk6m70 vKsa20CzeD9a/01BT2NCKk4h4jK/mXBSL120Om/eo2fPn6IcdjupAW/1e/bbw1MMs6OC Ec2+NQbDBR1aBhctRO5RrVf8TpIHJXpvdKdyQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=mU0TyVtSihfaTmsGqYiTiI/H8l7NPo3zjp07LPyppLTaF/M+AQ16UiqCJ7oCuMiwSK w3g3UQG0SD51DO6GYkEdO7k+r2nEbsH7MFO8WUD1gbFXCX2HRsUhlmVBhpxdZTR7ncQs po4BEauL/Et3NYzwEr0j8YTWVogJSqXx2+Dvo= MIME-Version: 1.0 Received: by 10.140.139.3 with SMTP id m3mr455212rvd.270.1232629859071; Thu, 22 Jan 2009 05:10:59 -0800 (PST) In-Reply-To: <6E01DF250C3B49319EE799C717FAC6C1@pc> References: <49778E0A.5010806@grudl.com> <6E01DF250C3B49319EE799C717FAC6C1@pc> Date: Thu, 22 Jan 2009 11:10:59 -0200 Message-ID: To: "Stan Vassilev | FM" Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Enhanced __CLASS__ constant From: guilhermeblanco@gmail.com (Guilherme Blanco) Why not just enhance get_class() function to accept the object itself (not only the instance)? This means: - No new keyword - No magic Foo::__MIRACLEHERE__ - No 50 pages documentation to help user Regards, On Thu, Jan 22, 2009 at 5:24 AM, Stan Vassilev | FM wrote: > > >> 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 us= ing >> well known magic constant in new context: >> >> Example: >> >> function factory($class) >> { >> return new $class; >> } >> >> $obj =3D factory('MyClass'); // returns object MyClass >> $obj =3D factory(MyClass::__CLASS__); // returns again object MyClass, c= ode >> is little bit more selfexplaining > > > Hi, > > I've discovered this omission earlier and I have proposed two solutions: > > 1) $x =3D nameof Foo; > > -or- > > 2) $x =3D Foo::__NAME__; // very similar to yours, Foo::__CLASS__ may eve= n be > better > > Since passing identifier references as strings is relatively pervasive in= a > lot of the PHP code out there, I hope this is resolved for 5.3, before we > figure out we need it the hard way after we've littered our code with ton= s > of manually written out explicit references. > > One problem with your proposal / my second proposal is, it works for > classes, but doesn't address namespaced 1) functions 2) constants. > > A new keyword would address this, but then, who wants a new keyword, > right... > > Regards, > Stan Vassilev > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 Guilherme Blanco - Web Developer CBC - Certified Bindows Consultant Cell Phone: +55 (16) 9215-8480 MSN: guilhermeblanco@hotmail.com URL: http://blog.bisna.com S=C3=A3o Paulo - SP/Brazil