Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40536 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8413 invoked from network); 17 Sep 2008 02:24:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Sep 2008 02:24:07 -0000 Authentication-Results: pb1.pair.com header.from=jochem@iamjochem.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jochem@iamjochem.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain iamjochem.com from 194.109.193.121 cause and error) X-PHP-List-Original-Sender: jochem@iamjochem.com X-Host-Fingerprint: 194.109.193.121 mx1.moulin.nl Linux 2.6 Received: from [194.109.193.121] ([194.109.193.121:50794] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/0E-30574-74A60D84 for ; Tue, 16 Sep 2008 22:24:07 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id C43C6287118; Wed, 17 Sep 2008 04:24:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at moulin.nl Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (mx1.moulin.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c9JDXlbYmJ-8; Wed, 17 Sep 2008 04:23:57 +0200 (CEST) Received: from [10.0.13.104] (ip129-15-211-87.adsl2.static.versatel.nl [87.211.15.129]) by mx1.moulin.nl (Postfix) with ESMTP id BB6CC2870ED; Wed, 17 Sep 2008 04:23:56 +0200 (CEST) Message-ID: <48D06A3C.5080404@iamjochem.com> Date: Wed, 17 Sep 2008 04:23:56 +0200 User-Agent: Thunderbird 2.0.0.16 (Macintosh/20080707) MIME-Version: 1.0 To: Stanislav Malyshev CC: Ionut Gabriel Stan , internals@lists.php.net References: <46322.71759.qm@web36401.mail.mud.yahoo.com> <48D01749.9000105@zend.com> In-Reply-To: <48D01749.9000105@zend.com> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Namespaced function vs static method in global class From: jochem@iamjochem.com (Jochem Maas) Stanislav Malyshev schreef: > Hi! > >> ------------------------------------------------------------------------ >> 1. include.php > >> namespace Test; >> >> class Bar { public static function baz() { return 'namespaced static >> method'; } } >> >> function foo() { return 'namespaced function'; } >> >> >> ------------------------------------------------------------------------ >> 2. index.php > >> require_once 'include.php'; use Test::Bar; >> >> class Test { public static function foo() { return 'static method'; } >> } > > I would advise you to avoid calling your classes and namespaces by the > same name, for the sake of clarity - especially if you are going to have > identically named static functions in both. You can always have My::Test > instead, etc. essentially good advice, but completely dismissive of the underlying issue. > >> 2. How should I call the static method >> baz of class Bar in namespace Test with call_user_func > > call_user_func(array('Test::Bar', 'baz')). Remember, the true name is > always the full name. > >> 3. Is there no possibility to change your minds and replace the double >> colon with >> something else, likes a simple colon? > > With simple colon - not likely. what about a simple new concept then? > >> I find it very confusing to >> figure out what is what and the way I should call it. > > You should always use full name with call_*, reflection, variable class > names and other runtime constructs. You can use shortcuts with static > constructs - where you specify the class name explicitly. now that last point is darn good raw material for an upcoming namespaces guideline, don't mind if I pinch it do you?