Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51228 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99695 invoked from network); 6 Jan 2011 00:53:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jan 2011 00:53:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=martinscotta@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=martinscotta@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: martinscotta@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:62264] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/05-10843-7A2152D4 for ; Wed, 05 Jan 2011 19:53:59 -0500 Received: by iym14 with SMTP id 14so15867259iym.29 for ; Wed, 05 Jan 2011 16:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=ylHsl8hlUJjTa8WxvTs1wT6TpCzfrEgsho4+sJglpUg=; b=sw0EchnKky5iY1w1dkUEDIFIfNWZFw5/q36ssYg4JKNxs569fTBKNm1OVy9HnUU+ua 1tIzQEroKa0n0XqGhTOrYHuoXHwrZuZSd+lXKNs8JKBTe8+6W1QuOk9dzvS5aLxhYe/j unskv7XAcmb82h+bQtwHt36XFeZOiXwp7dffc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=OcyA5VJ8A7CprLq/ZvJpAnP6NJKbDuwRI8znOvWtP5DC68yw6wj8Sau0s2QttYwnZ3 DK6c31Dl4PymXcCDSE2/UEECvAlhnbK3vyHLub3rzl/6NSlwklEfX9hn/ig0Du1e9+tH MPCMDy7KDFamddZziL3MMaIy616+SX+tesI2o= MIME-Version: 1.0 Received: by 10.231.37.1 with SMTP id v1mr7459157ibd.176.1294275237023; Wed, 05 Jan 2011 16:53:57 -0800 (PST) Received: by 10.231.16.67 with HTTP; Wed, 5 Jan 2011 16:53:56 -0800 (PST) Date: Wed, 5 Jan 2011 21:53:56 -0300 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=0022152d5f0dbe90e7049922effe Subject: RFC: about class names as values From: martinscotta@gmail.com (Martin Scotta) --0022152d5f0dbe90e7049922effe Content-Type: text/plain; charset=ISO-8859-1 Hi all, RFC: about class names as values PHP uses class names as values, but only in a couple of places. String constanst after the "new" or "instanceof" operator --correct me if I'm missing others-- are treated as class names. if( $obj instanceof MyClass ) { // $obj is instanceof Bar/Foo/MyClass } but what happen if the class name is used on other places? function newInstance($class) { return new $class; } $obj = newInstance( MyClass ); // notice. undefined constant MyClass so you have to end up by writting.... $obj = newInstance( '\Bar\Foo\MyClass' ); which lacks of any semantic, it's not a class name, it's just a string. My idea is that PHP could include a constant on each class, a string with the full qualified class name echo MyClass::CLASS; // \Bar\Foo\MyClass $obj = newInstance( MyClass::CLASS ); As the "CLASS" is currently a reserved word is guarantied that nobody is using as it today. What do you think about? Martin Scotta --0022152d5f0dbe90e7049922effe--