Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40535 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37484 invoked from network); 16 Sep 2008 20:28:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2008 20:28:50 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.163 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.163 il-gw1.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.163] ([212.25.124.163:23691] helo=il-gw1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/20-30574-10710D84 for ; Tue, 16 Sep 2008 16:28:49 -0400 Received: from [192.168.17.29] ([192.168.17.29]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 16 Sep 2008 23:30:04 +0300 Message-ID: <48D01749.9000105@zend.com> Date: Tue, 16 Sep 2008 13:30:01 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Ionut Gabriel Stan CC: internals@lists.php.net References: <46322.71759.qm@web36401.mail.mud.yahoo.com> In-Reply-To: <46322.71759.qm@web36401.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Sep 2008 20:30:04.0588 (UTC) FILETIME=[006A66C0:01C9183B] Subject: Re: [PHP-DEV] Namespaced function vs static method in global class From: stas@zend.com (Stanislav Malyshev) 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. > 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. > 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. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com