从 PHP 代码差异中,您能看出哪些类和函数发生了变化吗?

发布于 2024-07-19 10:54:51 字数 643 浏览 4 评论 0原文

背景:

PHPDoc ( http://www.phpdoc.org/ ) 是一个出色的提取工具 您的类或方法的 html 文档来自您的注释 文件。 添加 PHPDoc 注释还有其他优点 - 如果您使用 像 Zend 或 Netbeans 这样的 IDE,它将使用 PHPDocs 向您展示 自动完成提示。

大多数问题跟踪器都有一个功能,您可以在其中承诺 版本控制系统有一个特殊的注释,并且它将 自动链接提交该问题。

所以这就是我想要的系统:我用特殊的代码提交一些代码 评论,我的问题跟踪器将其链接到一个问题。 然后它会查看 提交并找出我更改了​​哪些方法和类。 那么它 说“如果您正在寻找有关此问题的文档,请尝试 PHPDoc 的这些位:ClassX.FunctionY、ClassZ.VariableP”。 自动将用户引导至可能相关的文档。 我认为这将是一个很棒的功能。

问题:

所以缺少的部分是进行 PHP 代码差异,并且 找出哪些类和方法发生了变化。 任何人都有任何 一些可以做到这一点的代码的指针?

提前致谢, 詹姆士

Background:

PHPDoc ( http://www.phpdoc.org/ ) is a brilliant tool for extracting
html documentation of your classes or methods from comments in your
files. Adding PHPDoc comments also has other advantages - if you use
an IDE like Zend or Netbeans, it will use the PHPDocs to show you
autocompletion tips.

Most Issue trackers have a feature where you can commit into your
version control system with a special comment, and it will
automatically link that commit to that issue.

So here's what I want in a system: I commit some code with a special
comment, my issue tracker links it to an issue. It then looks at the
commit and works out what Methods and Classes I have changed. It then
says "If you are looking for documentation around this issue, try
these bits of PHPDoc: ClassX.FunctionY, ClassZ.VariableP". It
automatically points users to documentation that might be relevant. I think this would be a great feature.

Question:

So the piece that is missing is something to take a PHP code diff, and
work out what classes and methods have changed. Anyone got any
pointers on some code that can do that?

Thanks in advance,
James

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

扮仙女 2024-07-26 10:54:51

如果您使用 subversion,您可以看到项目中所有已更改文件的差异。 看看它们有何不同。

有些软件具有集成的 Subversion 支持,例如 Trac。

这是 TracDiff 的图片

If you are using subversion, you can see a diff of all the files that have changed in the project. And see how they are different.

There are software with integrated subversion support, like Trac.

Here's a picture of TracDiff

属性 2024-07-26 10:54:51

你需要一个能够深入理解PHP结构的工具,即能够像PHP引擎一样解析PHP源文本。

我们的“智能差异”可以做到这一点,可以比较您知道是原始版本和更改版本的 PHP 文件对。 它会比较 AST 并找到将一个映射到另一个的最小编辑。 如果新旧方法完全相似,它会发现这一点并告诉您如何编辑其中一种方法以获得另一种方法。 请参阅http://www.semdesigns.com/Products/SmartDifferencer/index.html

You need a tool that understands the structure of PHP deeply, that is, can parse the PHP source text just like the PHP engine does.

Our "Smart Diff" does this, enabling one compare pairs of PHP files that you know are the original and changed version. It compares ASTs and finds the minimal edits to map one into another. If the old and new methods are at all similar, it will discover that and tell you how one was edited to get the other. See http://www.semdesigns.com/Products/SmartDifferencer/index.html

〃温暖了心ぐ 2024-07-26 10:54:51

https://www.php.net/reflection

PHP5 有方法来分解一个类并检查所有类方法,包括给我需要与差异匹配的行号。 使用这个我可以开始手动推出我自己的解决方案。

https://www.php.net/reflection

PHP5 has methods to take a class apart and examine all the methods, including giving me the line numbers I need to match against the diff. Using this I can start to hand roll my own solution.

本王不退位尔等都是臣 2024-07-26 10:54:51

您可以编写一个提交后脚本来接收修改的文件并查看它们以执行您想要的操作

you can write a post commit script that receives the files modiefied and looks into them to do what you want

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文