drlq92444 2019-04-17 03:24
浏览 167

将具有多个类的php文件拆分为具有命名空间的类文件

Have a large file with 130k lines ~2k classes in it each encapsulated in a if(!class_exists()){}.

Objective is 2k individual class files with namespaces (currently none) from this data. Will use a parent namespace (let's call it Parent for now) and then first part of class name will be child namespace so. Example:

<?php
if (!class_exists('ThisClassName'){
    class ThisClassName {}
}
if (!class_exists('ThisOtherClass'){
    class ThisOtherClass{}
}
if (!class_exists('ThatClassName'){
    class ThatClassName {}
}
if (!class_exists('ThatOtherClass'){
    class ThatOtherClass{}
}

This will end up in this hierarchy:

src/ (root)
  This/
    ThisClassName.php
    ThisOtherClass.php
  That/
    ThatClassName.php
    ThatOtherClass.php

Example file:

<?php
namespace Parent\First;
class FirstClassName {}

Thoughts on how to start writing this script? Language for the file is PHP, though that's not required for any of the extraction scripting. Also consider any valid PHP could be in there for regex purposes.

P.s. For anyone curious this is NetSuite's PHP Toolkit (2016-2018, hopefully they wise up in 2019 and move to PSR)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料