Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66180 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1884 invoked from network); 25 Feb 2013 10:08:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2013 10:08:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.179 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.212.179 mail-wi0-f179.google.com Received: from [209.85.212.179] ([209.85.212.179:42834] helo=mail-wi0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/73-10787-F183B215 for ; Mon, 25 Feb 2013 05:08:32 -0500 Received: by mail-wi0-f179.google.com with SMTP id ez12so2958709wid.0 for ; Mon, 25 Feb 2013 02:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=rhb8d1OwGMyBJZV087sw5h3RY1jUcALD8zxjpb6tdVg=; b=FC1sV8+vaF+fL1d4NRb8p1mk9NwJMKWvSUyoLOHFzLUtc7wKj6/zrrbO36QMafogb8 ASTMfzTQn7ScgXdSc462KMmFL6oHN9dchQKHwaoWUrrPXM8i0RVDEFyFtBsL/tYMfG+W +uUg/RfXgqrbshwkr5LONTszRUZssujtvICx5TY69Rglw/doOevXMxMRFfBkCGhWMKNX 1a/R/mmc8GwfpMEMKxwqDGB5vHmS/cbT9/bH/tLHoa75TL5QsGCs+VEZHX0mCAAUJ/Z1 ePC/5vdiqezUQbq2sLY4ULJDTRAGAOnB421FuwOglnJExNx17PV+Ow54T1u2gceXm11X qPkA== X-Received: by 10.180.105.232 with SMTP id gp8mr10714485wib.33.1361786908850; Mon, 25 Feb 2013 02:08:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.98.197 with HTTP; Mon, 25 Feb 2013 02:08:08 -0800 (PST) In-Reply-To: <01F30F77-B22D-40CE-ADF1-AC1C488FE39D@me.com> References: <01F30F77-B22D-40CE-ADF1-AC1C488FE39D@me.com> Date: Mon, 25 Feb 2013 11:08:08 +0100 Message-ID: To: Jens Riisom Schultz Cc: PHP internals list Content-Type: multipart/alternative; boundary=f46d044402d0f63a5804d689b85b Subject: Re: [PHP-DEV] Late FQCN resolution using ::class From: krebs.seb@gmail.com (Sebastian Krebs) --f46d044402d0f63a5804d689b85b Content-Type: text/plain; charset=ISO-8859-1 2013/2/25 Jens Riisom Schultz > 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" */ > } > } > ?> > Without testing anything: My first idea would be 'static::class'. Did you tried this? > > 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 > > -- github.com/KingCrunch --f46d044402d0f63a5804d689b85b--