douxie4583 2010-07-15 12:21
浏览 24
已采纳

PHP重命名外部库

I have a library "Google" that I keep in a separate GIT repository.

This library is used in some projects. The problem is that I want to rename the library to match the naming convention of these projects, e.g. "Service_Google".

Since PHP doesn't allow for automagic refactoring, the best way I've come up with is to do the following.

  1. Clone the repo
  2. Use regex search and replace to change every class name and reference
  3. [use it until there's a new version]
  4. Revert
  5. Pull the latest version
  6. Step 2

There must be a better way, right?

  • 写回答

2条回答 默认 最新

  • dstd2129 2010-07-15 12:39
    关注

    I would work very hard to avoid changing an external library in any way. Even apparently benign changes such as name changes can be fraught with danger. The sheer hassle of needing to make those changes every time you take a new version is to me unacceptable.

    I would also say that the motivation of bending Google's stuff to conform to your naming convention is rather suspect. Should we take this further? Colour for Color? Oui for Yes if we're working in France? (I mean in variable names and function names not in presentation.)

    I would even avoid using class_alias for this purpose. You give a new developer, who happens already to be familiar with the external library, a headache.

    Bottom line: there are times to go with the flow, embrace the library that you are using, control the things you own.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题