Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37690 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64953 invoked from network); 17 May 2008 00:10:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 May 2008 00:10:10 -0000 Authentication-Results: pb1.pair.com header.from=sv_forums@fmethod.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sv_forums@fmethod.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fmethod.com from 69.16.228.148 cause and error) X-PHP-List-Original-Sender: sv_forums@fmethod.com X-Host-Fingerprint: 69.16.228.148 unknown Linux 2.4/2.6 Received: from [69.16.228.148] ([69.16.228.148:55279] helo=host.fmethod.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/C7-18477-1622E284 for ; Fri, 16 May 2008 20:10:10 -0400 Received: from [83.228.56.37] (port=4389 helo=pc) by host.fmethod.com with esmtpa (Exim 4.68) (envelope-from ) id 1Jx9zy-0000Z6-VT for internals@lists.php.net; Fri, 16 May 2008 19:10:07 -0500 Message-ID: To: "internals Mailing List" References: <482B9F96.7050908@gmail.com> <482CE5F8.5000700@gmail.com> <4D.AE.00945.5066D284@pb1.pair.com> <482D9F66.4000802@chiaraquartet.net> <2DA61F1F6DB245F5A628540F51AAE45F@pc> <482DDF8F.7070005@zend.com> <208411A24212429683264E1E5C89980F@pc> <482E1CB6.7030601@zend.com> Date: Sat, 17 May 2008 03:10:00 +0300 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="ISO-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.fmethod.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - fmethod.com Subject: Re: [PHP-DEV] Re: 5.3 Namespace resolution rules suggestions From: sv_forums@fmethod.com ("Stan Vassilev | FM") >> internal or user. But in namespace context I'll have to do something >> along the lines of: >> >> if (function_exists('json_encode')) { >> $encoded = json_encode($raw); >> } else { >> $encoded = ::json_encode($raw); >> } > > What this code is supposed to do? If it's supposed to call namespace's > json_encode in case global one is not defined, I see nothing wrong with > it. If it is intended to call globally defined json_encode, then you just > write ::json_encode, no ifs. The thing is you'd need to do it *ONLY* for > json_encode, and only because you want to do something special with it. > The principle is - common case is free, special cases are available, but > for a "fee" - additional code. The code is supposed to call the global internal json_encode() if it exists, and if not, call global user json_encode(). Without namespaces this is achieved in the following way: $encoded = json_encode($raw); // global user or global internal, doesn't matter, it's transparent. But inside a namespace, you'll need to do the above checks since internals and user functions don't resolve under the same rules.