Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34212 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82829 invoked by uid 1010); 22 Dec 2007 00:03:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 82813 invoked from network); 22 Dec 2007 00:03:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2007 00:03:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=malterisio777@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=malterisio777@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.191 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: malterisio777@gmail.com X-Host-Fingerprint: 209.85.198.191 rv-out-0910.google.com Received: from [209.85.198.191] ([209.85.198.191:40147] helo=rv-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/00-16789-D245C674 for ; Fri, 21 Dec 2007 19:03:02 -0500 Received: by rv-out-0910.google.com with SMTP id k15so413897rvb.23 for ; Fri, 21 Dec 2007 16:02:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=vQxogfpP76OaesmZEx3ITQtMx4q8eHug5fNSm5Fqk+M=; b=dr4fjUwKclOCPUUfglihaxm+nosr/u4xqjngPwH1pUNUFD2IzWsL2OdFQ9VL0bZoJQPQGbz8GPzTreZSaq/HhEzUWwtHg+ibcy6FduBbrX4EwvGv8L9l48v2Q43Vrqiq0Xy9F2FPkfTUUPt8kXHC2jo2hWDWqK0S2uPRxjeQk2s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=j6ETU0RX1VQScCOZas5k+NEsjNdVV9B1SWgTY6abx/nKmAHCfjPT9tjhaznCNk923iPTlNqtkjFwebBL/zS5XLbSJvfAy3KlriES/IDRud4ACj1zdyOIl4/3iRWSex1XoaxTCYY+YHyWDMRYhPLYh+GDlmJkTPG5PEkejVTuTcY= Received: by 10.142.241.10 with SMTP id o10mr982104wfh.155.1198281757573; Fri, 21 Dec 2007 16:02:37 -0800 (PST) Received: by 10.142.157.9 with HTTP; Fri, 21 Dec 2007 16:02:37 -0800 (PST) Message-ID: <52dbac0f0712211602y5296932bt72ac90fb577c6af5@mail.gmail.com> Date: Fri, 21 Dec 2007 21:02:37 -0300 To: "Paul Biggar" Cc: "PHP Developers Mailing List" In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2160_22622057.1198281757538" References: <52dbac0f0712211230v17c0762cs4b9e37db29e2bc34@mail.gmail.com> Subject: Re: [PHP-DEV] Refactoring code for namespaces appliance From: malterisio777@gmail.com ("Martin Alterisio") ------=_Part_2160_22622057.1198281757538 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/12/21, Paul Biggar : > > Hi Martin, > > On Dec 21, 2007 8:30 PM, Martin Alterisio wrote: > > I've been pondering about how to algorithmically/mechanically prepare a > non > > namespaced code for namespaces appliance. This would be a first step > which > > will just prepare the code for namespaces in a safe way, but not to > profit > > from aliases created by use. The latest will have to be implemented > manually > > (IMHO). > > phc (www.phpcompiler.org) would be suitable for this purpose. It has > good support for nearly all of the features you need. Thank you, that looks like it's the tool for the job. > 4) find all function calls (not method calls) which are not keywords > (array, > > isset, unset, list, etc) and prefix them with :: > > list, array etc wouldnt be confused with functions. Functions are just > methods without target. You'd need a short list of functions such as > empty, unset etc to avoid. I didn't quite understand your point here. If you can elaborate a little more. Take into consideration that the reason here for the distinction between function calls which are actually keywords are due to the fact that the following wouldn't be valid: if (::isset($var)) { Because isset is actually a keyword. And to ensure that the code is ported safely to code which uses namespaces, the function calls which point to globals or internal functions, should be prefixed with :: > 6) find static method calls with variables used as class name, and mark > them > > for user handled refactoring > > I'm not sure why this couldnt be done automatically, but finding > static method calls is also easy. You could add comments to mark these > fairly easily. Maybe some workaround can be found to str_replace the namespace separator, but I think this wouldn't be optimal and possibly harm code readability and maintainability. Consider a factory method: An automated refactoring would be tempted to do: Which I think is not the proper way to refactorize this code. This would be, IMHO, the right way to refactorize this code: Considering the variants and possible uses of this syntax, I'll say it's better to leave this job to the coder rather than to an automated job. Thank you for your response. Best Regards, Martin Alterisio ------=_Part_2160_22622057.1198281757538--