开发者

match php classes in a script and create separate files for each class found

开发者 https://www.devze.com 2023-02-12 17:05 出处:网络
My problem is with the regex to match classes and skip content that is within quotes. I also don\'t know how to skip the \'}\'s that are used to close methods inside the class, so the engine thinks th

My problem is with the regex to match classes and skip content that is within quotes. I also don't know how to skip the '}'s that are used to close methods inside the class, so the engine thinks that it is reaching the end of the class.

Later then I want to create separate files for each class matc开发者_C百科hed. For example:

{$classname}.php >> content

This is needed because I have the terrible practice of start coding many classes in one file and then only when I've got something "meaty" then I decide to put them in separate files, which of course is too boring and spend a lot of my time. Could you help me with this please? Specially the regex, but feel free do the rest ;)


Regex is not designed to parse programming languages (specifically nesting). Get an IDE that has refactoring tools if you want help moving code around.

0

精彩评论

暂无评论...
验证码 换一张
取 消