Re: CamelCase conversion to proper_c_style
| From: | Nathan Rixham | Date: | Mon, 27 Apr 2009 14:02:41 +0000 |
| Subject: | Re: CamelCase conversion to proper_c_style | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292019@lists.php.net to get a copy of this message | ||
tedd wrote:
At 9:40 AM +0100 4/27/09, Richard Heyes wrote:whereas I'd say it shouldn't be a problem to do automatically (but will be); just only use a tokenizer and not any form of regex or str_replace etc, that way you can be sure you are ONLY changing classes, methods, functions, function calls, variables etc you still may have some problems with any call_user_func or string references though!Hi,Not only that. but it you leave each function alone until you work on it, then you'll have at least some indication of where/when an error has been introduced. Many time when I'm using a piece of code that isn't formatted as I like, I first get it to work as I want changing only the functions that I must change. After everything is working, I then step through the code, reformat, and change in small steps. HTH's teddI know it's probably heresy for a lot of coders, but does anyone know a function or class or regexp or somesuch which will scan through a PHP file and convert all the CamelCase code into proper C-type code? That is, "CamelCase" gets converted to "camel_case". I snagged a bunch of someone else's PHP code I'd like to modify, but it's coded the wrong way, so I'd like to fix it. (I'm teasing you CamelCase people. But I really would like to change this code around, because it doesn't happen to be my preference.)I'd say, if you must, then change as you go. If you do it all in a oner you'll likely introduce a shed load of problems. -- Richard Heyes