Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62991 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92540 invoked from network); 13 Sep 2012 21:42:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2012 21:42:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=ralph@ralphschindler.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ralph@ralphschindler.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain ralphschindler.com from 209.85.214.170 cause and error) X-PHP-List-Original-Sender: ralph@ralphschindler.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:35852] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D4/5B-31416-A2352505 for ; Thu, 13 Sep 2012 17:42:02 -0400 Received: by obbwc18 with SMTP id wc18so5737067obb.29 for ; Thu, 13 Sep 2012 14:41:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=6QERoLQS4eRR7KrdU49ouF6f+1vCO2L+5RT/CnshehM=; b=kzJbo3hWJxbFvJPDz+tS5RVwnaUbjSReYxmmsbIpj5p4/gf9e+n/m+vskp6qREt4K8 laxXPI8x4hh8bvj+WiUEehwFwRVeWQEssHHWTTDnVlZirysoTYZ+Bk+8u9HPvGF0XdK/ 2FmmxQgmcYJ+wniLVM+ChkIcB0PNReX0FcrpMeaTrtY84aktRbTOCH9MGTkP80+4tfDg EjYLiqzsFQLtwjWfvtmwtFU8wwfywv8fhCuvifdeogxbU+Ide5rwBjFNCOsGUDH+y8RE twPCmCWFCJCKEgnCZQw2eayA7HiOYyl/mOoGcsiD0LbJdslXy9h4dWzz17K+K7HE943m VguQ== Received: by 10.60.171.174 with SMTP id av14mr728355oec.61.1347572519648; Thu, 13 Sep 2012 14:41:59 -0700 (PDT) Received: from Ralphs-Mac-Pro.local (ip174-73-14-247.no.no.cox.net. [174.73.14.247]) by mx.google.com with ESMTPS id qd7sm25226053obc.5.2012.09.13.14.41.58 (version=SSLv3 cipher=OTHER); Thu, 13 Sep 2012 14:41:59 -0700 (PDT) Message-ID: <50525325.2090104@ralphschindler.com> Date: Thu, 13 Sep 2012 16:41:57 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: Stas Malyshev CC: internals References: <504F4D33.4070306@ralphschindler.com> <50524989.10204@ralphschindler.com> <50525064.9090009@sugarcrm.com> In-Reply-To: <50525064.9090009@sugarcrm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQlsSOXKaF13UHx4fHzD0Gb34l1IFWbQJO56MCklnKuNvpv53GDQYF7EWWVgflXcZ0yJEiLX Subject: Re: [PHP-DEV] Re: [VOTE] ::class feature to resolve namespaced class names to scalars From: ralph@ralphschindler.com (Ralph Schindler) Hey Stas, >> * Here are the edge cases / implementation details that need a decision: >> >> - $variable::class (should it even be supported?) > I don't see it doing anything useful. I generally agree. In the current patch, this does not work and would need another run in the parser. >> - self, static, parent::class not in a class definition >> - self, static, parent::class in a method signature >> - self, static, parent::class in a method body > > In constant context, self:: may work, but static:: can't work for > obvious reasons. parent:: can be made work too I think - though the > class may not be known at the run time, its name should be. self works in compile-time in the current patch. static::class and parent::class work in the current patch in run-time, but they are effectively doing a get_called_class() and get_parent_class() respectively. This part of my implementation can be cleaned up to remain in runtime but utilize zend_do_fetch_class() instead. > As for runtime context, static:: can be made work too but I wonder why > bother if we have perfectly good get_called_class()... For some people, I think it's a matter of completeness, regardless if it is a compile-time name resolution or a runtime class lookup. Personally, (I am not the majority here I feel), I'd rather see zend_error(E_FATAL) for any runtime lookups, forcing people to use the runtime-lookup-isms (like get_called_class(), or get_parent_class()). For the latter, returning "false" there seems more likely, where as parent::class returning false when not in an inherited class seems odd to me. -ralph