具有最佳代码完成功能的 PHP IDE?

2022-01-20 00:00:00 ide code-completion php

尽管 有些人可能会说,我相信代码完成(又名 Intellisense)是代码编辑器的第二个最佳发明(第一个是语法着色).它确实使编码更容易,因为我不必担心我是否将函数命名为 CalculateReportSumsReportSumsCalculate 或只是 GetReportSums.

Despite what some might say, I believe that code completion (aka Intellisense) is the second best invention when it comes to code editors (the first being syntax coloring). It really makes coding easier because I don't have to worry whether I named the function CalculateReportSums, ReportSumsCalculate or simply GetReportSums.

不幸的是,我还没有找到一个代码编辑器可以令人满意地为 PHP 实现此功能.令人满意"是指与 Visual Studio for C# 一样好".

Unfortunately I have not yet found a code editor which would satisfactory implement this feature for PHP. And by "satisfactory" I mean "as good as Visual Studio for C#".

我首选的文本编辑器是 Notepad++,但它只有一个 PHP 的内置函数列表,而且只有在你按下 Ctrl+SPACE 后才会出现.我也尝试过 Eclipse+PDT,它更好,但仍然经常出现打嗝,有时无缘无故完全失败(没有可用的列表),并且总是仅在我暂停输入时出现(将超时设置为一些小的值会导致列表不完全出现).

My first choice of text editor is Notepad++, but that only has a list of PHP's built-in functions, and it only appears after you hit Ctrl+SPACE. I've also tried Eclipse+PDT, which is better, but still often has hiccups, sometimes fails altogether for no apparent reason (no list available), and always appears only when I pause typing (setting the timeout to some small value causes the list not to appear altogether).

那么 - 那里有更好的东西吗?能够知道当前范围内的所有变量、能够遵循 include() 并在我键入时实时显示列表的东西?

So - is there something better out there? Something that would be aware of all the variables in the current scope, that would be able to follow include()s, and would display the list in real-time as I type?

我知道 PHP 是一种动态语言,原则上完美的代码补全是不可能的(因为直到运行时你才知道会有哪些变量存在),但应该仍然可以将它实现到相当好的水平学位 - 比我目前看到的要好得多.

I know that PHP is a dynamic language and a perfect code-completion is impossible in principle (because you don't know what variables will be there until runtime), but it should still be possible to implement it to a fairly good degree - much better than what I've seen so far.

添加:添加一些小问题 - 我希望 CC 是即时的,就像在 Visual Studio 中一样.我输入一个字符,列表同时显示.我输入另一个字符,列表在我眨眼之前就变成了一半大小.近乎零的 CPU 使用率,即时结果(向缓存之神致敬!).

Added: To add a few minor points - I want the CC to be instantaneous, like in Visual Studio. I type a character, and the list shows at the same instant. I type another character and the list becomes half the size before I can even blink. Near-zero CPU usage, instantaneous results (all hail the Gods of caching!).

另外 - 我很擅长以特殊方式记录我的函数甚至变量.我更喜欢 PHPLint 语法(因为以​​后我可以用它检查我的代码),但其他语法也可以.强迫这样做也有利于你的评论纪律.:)

Also - I'm fine with documenting my functions and even variables in a special way. I prefer PHPLint syntax (because then I can check my code with it later), but other syntaxes will do as well. Forcing to do this is also good for your commenting discipline. :)

推荐答案

我发现 Netbeans 的代码完成比 Aptana 更好.当我使用 codeigniter 时,Netbeans 会在 Aptana 不会的模型中为我的静态方法编写完整的代码.

I have found that Netbeans has better code completion than Aptana. When I was working with codeigniter, Netbeans would code complete for my static methods in models where Aptana wouldn't.

自从我发布这篇文章以来,JetBrains 已经发布了 PHPStorm 并拥有你的快速智能感知,以及更好的类型提示.它绝对优于所有其他恕我直言.我已经免费使用 EAP 2.0 几个月了.

Since my posting of this, JetBrains has released PHPStorm and has your rapid fire intellisense, as well as even better type hinting. It is absolutely superior to all others IMHO. I've been using EAP 2.0 for several months now for free.

相关文章