Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66179 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 537 invoked from network); 25 Feb 2013 10:07:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2013 10:07:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 74.125.82.44 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:64272] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BC/23-10787-DC73B215 for ; Mon, 25 Feb 2013 05:07:10 -0500 Received: by mail-wg0-f44.google.com with SMTP id dr12so2194424wgb.11 for ; Mon, 25 Feb 2013 02:07:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=/M8g3JRbXZI2V2FXkjjHXTr2BmgcRgXyxgT5x7YCXSs=; b=IfJmqPEyvZiOdgaQW4gVV3fVuq9wRCiwge8USKo1ddgbh4DCKMT0jSDRFUMlVxuZz9 fooclsIcfklPENJJo4a2LfiYivmU6lgpdd3oBQCxHSi4JQi5RPZ2DLWRcJb+RoBleDZl SoLf8Srm/mT0Frc3XfNrHv8f+CBNy7/pgzMao2nX7exSvhFRMC8mqSm1dSlnyWaAEmKQ AUjTsdpbMCSJj34Aid0jazVrtAF8Z67265nULyWiWo39umNwfOp2WHxdmKgf9jB8z78H cHtj4VK45F1BFx9ohffcBZvProeKqJa5gyyeJ4zRPnbzprPGOOJ6Ts7ciu8cFzsrsFOX nc5Q== MIME-Version: 1.0 X-Received: by 10.180.97.233 with SMTP id ed9mr10737277wib.32.1361786826892; Mon, 25 Feb 2013 02:07:06 -0800 (PST) Received: by 10.194.5.233 with HTTP; Mon, 25 Feb 2013 02:07:06 -0800 (PST) X-Originating-IP: [77.13.223.70] In-Reply-To: <01F30F77-B22D-40CE-ADF1-AC1C488FE39D@me.com> References: <01F30F77-B22D-40CE-ADF1-AC1C488FE39D@me.com> Date: Mon, 25 Feb 2013 11:07:06 +0100 Message-ID: To: Jens Riisom Schultz Cc: PHP Internals Content-Type: multipart/alternative; boundary=f46d044306aa13c21604d689b4dd X-Gm-Message-State: ALoCoQljx8w8DWQ9VOyEJxmF8H4kmZxuixUjhd3WrKIFHOOONe5pTmyv0SmnhB5tw68r0kxmLHhG Subject: Re: [PHP-DEV] Late FQCN resolution using ::class From: kontakt@beberlei.de (Benjamin Eberlei) --f46d044306aa13c21604d689b4dd Content-Type: text/plain; charset=ISO-8859-1 You can use the "static" late static binding keyword for this, it works, see: http://3v4l.org/l9Z5Y On Mon, Feb 25, 2013 at 11:00 AM, Jens Riisom Schultz wrote: > Hi everybody, > > I have read up on this, and done some testing. > > First up, my findings with PHP5.5 alpha5: > > namespace spacy; > > class classy { > public static function fqcn() { > /* This works but is not useful enough: */ > //return self::class; > > $me = 'classy'; > > /* This just doesn't work, but I wish it did: */ > //return $me::class; > > /* This simply does not work as expected: */ > return eval("return $me::class;"); > /* Output: "classy" - Expected output: "spacy\classy" */ > } > } > ?> > > I'm trying to late resolve a class name contained in a variable to the > FQCN. I understand that this is hard (maybe even impossible) with the > current implementation, because class name resolution happens compile time, > but eval("return $me::class;") simply returns something that is weird. > > I guess what I'm trying to ask is whether it would be impossible to > support late FQCN resolution in any way? It would be very useful for > frameworks to be able to do this. > > - Jens Riisom Schultz > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d044306aa13c21604d689b4dd--