News for PHP in KDevelop
So, after a period of silence I present you an unsorted list of features and bug fixes I did to the PHP plugin for KDevelop in the last few weeks:
added support for path autocompletion after require / include statements: This shares code with the Cpp plugin and it’s completion after #include. I plan to use this autocompletion eventually also for functions accepting filenames or paths. Think of fopen, file_get_contents etc. pp. So far only URLs that are covered by an open project can be completed. We will need support for custom include paths so we can support e.g. global PEAR or framework installations.
worked around a bug where the “schedule all project files for parsing” had no affect. Apaku is currently working on making some internal changes so I can remove the workaround and fix this properly. With this fixed/worked around you should retry the PHP plugin along with frameworks or similar to see how well it works. Just make sure to have the framework inside your project so it gets parsed.
fixed code completion of static class members for classes that where not defined in the current file
by sharing code with the cpp plugin I made it possible to show information about includes on hover. You can open the file from that popup or just see what classes, functions, variables etc. are defined there and jump to them quickly.
report errors when the user tries to include a directory
totally rewrite a huge part of the code completion: It now utilizes the token stream and can hence work much more reliably. Also the code is much cleaner in my opinion and it should be easier to extend its functionality. If you spot places where you think no code completion should happen or vice versa, please report that to me!
don’t crash on empty includes (i.e.
include "";
)ignore xml declarations (i.e.
<?xml ... ?>
)support implicit declarations of referenced arguments, esp. important for e.g.
[preg_match](http://www.php.net/preg_match)("#...#", $string, $matches);
, before the$matches
was said to be undefined. Additionally references should be marked and shown as such now in the popups of e.g. function arguments.support implicit array declarations, e.g.
$a[0] = 1; // now $a is an array
fix bug which made the class browser not aware of changes in PHP class structures. Now we can see new classes, methods and members directly after writing them in a PHP file.
support
/// comment
syntax for doc-comments, especially useful for type hints of variables.report error when someone tries to declare a class constant with an invalid type (i.e. not bool, int, float or string)
I’m very happy to say that we seem to get more and more (happy) users!
Comments
Want to comment? Send me an email!
Comment by Alex (not verified) (2009-08-17 16:44:00)
Thanks! I just started using it, looks really nice!
One note however: Could you please disable auto-completion in comments (like in C++)? It really gets in a way of writing documentation.
Thanks again!
Comment by Milian Wolff (2009-08-17 19:50:00)
done :)
Comment by Alex (not verified) (2009-08-17 22:21:00)
Hey, you’re fast! :)
I’ve got a some additional comments, if you don’t mind :)
Typing (“less than”)php shouldn’t pop up a completion. The form seems to reject the tag opener symbol, so I typed it as “less than”.
Every edit causes the editor to flash (visible with bold symbols - they turn normal and blue for a moment, then bold and black again). This happens even if I just type a space somewhere. I guess it’s due to reparsing, but it’s somewhat annoying having the screen flash on every key press.
For some reason, the following code causes “$_gen_flags = array();” to be underlined as error:
It would be nice if the project view allowed expanding directories which are symbolic links. I have several projects which share a common library, which is symlinked there for convenience and actually copied there only when making a distribution.
It seems that the parser is case-sensitive for function names. I have some is_NULL() invocations which it flags as incorrect (is_null() is ok).
I’m also experiencing some random crashes during file parsing, but I cannot pinpoint it to any specific piece of code. The crash handler doesn’t launch at all, or isn’t able to load any information. Easy to reproduce with taking a phpmyadmin distribution (I’m using phpMyAdmin-3.1.5-all-languages) and making a project out of it. The segfault happens at 0% or 1% of parsing.
Thanks for the awesome work you’re doing, Alex
Comment by Milian Wolff (2009-08-18 17:02:00)
I could open and parse the newest phpMyAdmin distribution. I fixed a crash last day so maybe that was it. Please check again with an updated php plugin.
Comment by Alex (not verified) (2009-08-19 19:30:00)
Some more notes:
I get a reproducible crash when typing define(); (with empty parentheses).
Also, I think that completing public function names in define(” is unnecessary. Actually, I don’t think that completing function names in strings is necessary at all. While there are cases when a function name is used in a string and called afterwards, usually these are the cases where completion won’t help anyway.
Thanks. Alex
Comment by Milian Wolff (2009-08-19 23:19:00)
Could you please create a wishrequest on bugs.kde.org? When you are asked for the component, use the linedit to search for “php” and pick the php language support component in the results. See also this page for more information: http://techbase.kde.org/Development/Tutorials/Debugging/How_to_create_us…
And that define bug I just fixed. Thanks for the report!
Comment by Alex (not verified) (2009-08-20 11:52:00)
Done, https://bugs.kde.org/show_bug.cgi?id=204500 .
For the crash information, see the post above. Should I also file bugreports/wishlists for the stuff I wrote about earlier?
I have to say this again - HUGE thanks for the work you’re doing. I actually started a new project a couple of weeks ago (C++/Qt on the client side, PHP/C++ on the server side), using KDevelop4 from the start. KDevelop4 is turning out to be (actually, already is) a fantastic platform for development. So, Thanks again!
Alex
Comment by Alex (not verified) (2009-08-19 14:02:00)
Nope, still crashes (current kdevelop, kdevplatform and php plugin SVN).
I run it through valgrind (with auto-loaded phpmyadmin project at startup) and there are some errors, see: http://pastebin.ubuntu.com/255703/ . Maybe one of these errors is causing the crash.
Also, I should have mentioned I’m on x86_64 (openSUSE 11.1, gcc 4.3.2).
Thanks a lot for your work. Alex
Comment by Milian Wolff (2009-08-19 22:45:00)
Could you probably find out if I can get that version of phpmyadmin somewhere?
Oh and please give ma a backtrace from gdb, I’m not really acquainted with valgrind and can’t see anyting php-related producing a crash in there…
And I doubt 64bit is the culprit, but you’ll never know… let me try to reproduce it on 32bit and then we’ll see!
Comment by Alex (not verified) (2009-08-20 10:58:00)
I still get a crash even with the latest phpmyadmin, 3.2.1.
However, I think I found the source of the problem. I had set “Background Parser -> Maximum number of threads” to 2. When I set that value to 1, the crash is gone. You may need a dual-core CPU to reproduce the crash on race conditions though.
GDB is usually useless in case of race conditions and memory corruption, but here it is anyway: http://pastebin.ubuntu.com/256203/ (KDE crash handler shows no information at all, so I had to do it the manual way; I hope I did it right - I don’t use the command-line gdb that much).
Should I file a bug report about this?
P.S. Valgrind has a race condition detector, so it may be helpful in debugging this problem.
Thanks a lot. Alex
Comment by Milian Wolff (2009-08-18 01:40:00)
No, not at all. I really appreciate that you seem to like it.
I think you mean
< ?php
shouldn’t popup a completion. Actually I had a unit test for that but it didn’t catch that one, thanks. I fixed it.Yeah I find that pretty annoying as well, but this is pretty low-priority to me. Comparing to Cpp I think we always reparse the whole document instead of just the most recent context that was edited or something like that. And probably we add/remove the highlighting at the wrong positions. I’ll look into it eventually but right now I have more important stuff to fix imo.
Indeed, I have to fix that. Thanks for the report.
The other stuff I have to investigae.
Comment by tobias (not verified) (2009-08-16 13:18:00)
Hi there,
autocomplete on include/require is great - one tip though:
None of the IDEs I’m using (NetBeans, phpEclipse & PDT), support autocomplete for the following include-method:
require_once( dirname(FILE) . ‘/../include/myAutoload.php’ );
This method is used by many libraries and software packages since it ensures correct inclusion without the necessity to set any special include-path.
Comment by Milian Wolff (2009-08-16 14:42:00)
Yes, I use that myself hence I’ll eventually add support for that. Lets see - maybe I can do that right away :)
Comment by Milian Wolff (2009-08-16 17:19:00)
Ok, got something hacked together. Still some issues but should work most of the time. But remember that you need to do this:
include dirname(__FILE__) ."/...
Especially the / is important.
Comment by Anonymous (not verified) (2009-08-16 11:29:00)
congrats for the php in kdevelop… i hope to see one the support for ruby/ror too… :)
Comment by DanaKil (not verified) (2009-08-16 10:14:00)
I will update right now, thanks :)
Comment by Blizzz (not verified) (2009-08-16 10:04:00)
Great news, keep up the good work! Will build it from source right now :)
Have a nice sunday, Arthur
Comment by Anonymous (not verified) (2009-08-16 09:16:00)
Nice work!
Will my kdevelop autoupdate or have i to install it manually? In that case, how? Thx!
Comment by Milian Wolff (2009-08-16 12:18:00)
This depends. If you distribution supplies you with packages for KDevelop 4 and the PHP plugin which are both not yet released as stable versions, you might have luck and it will autoupdate.
But I bet you’ll have to update it manually, i.e. build from source. See this article for a howto: http://milianw.de/blog/building-kdevplatform-kdevelop-and-the-php-plugin…