Code Completion unworkable in PHP classes?

I am working with PHPStorm Version 1.02 Build 95.503

I just started working with the demo and have been enjoying many of the features thus far.  However, when I recently started writing some classes in PHP, none of the built-in PHP functions (such as is_array()) pop up if I hit control+space after typing the first couple of letters of the function.  Only a small, blank bluish box shows up under the blinking cursor.  The PHP globals (like $_SERVER) WILL show up if hit control+space after $_ however.  

I define my classes with the .class extension and have added *.class to my PHP file extensions in the IDE settings.  My files have this basic structure:

<?php
class MyClass {

    properties

    methods

}
?>

And that's all.  The same odd behavior occurs referencing class properties and methods within the class.  If I type:

$this->

and hit control+space, the same small, bluish box appears with nothing inside.  Accessing these methods and properties works fine as I include the classes in other PHP files and create objects with them.  I save the classes regularly as well so the property and method definitions all exist and have been saved before I'm trying to reference them with code completion.  I am writing the code within each method's curly braces of course and I even have valid phpDocumentor documentation for all of the properties and methods!

4 comments

Well, usually it works. Try executing File|Invalidate caches and restart the IDE.

0

Check, if your php-file are in project. When file not in project, "autocomplete" doesn't work.

0

Indeed, If you opened external file or excluded folder via Settings|Directories completion won't work.

0

I executed File > Invalidate Caches and, at first, it had only a minor effect.   Only functions/variables already used in the class were showing up for code completion and after $this-> was showing the pink "No Suggestions" box.  I started to type this post and went back to check and see if it was showing just local variables or local variables AND class properties and all of a sudden everything worked!  I guess the cache needs a handful of seconds to load everything?

So, in the end, executing File > Invalidate Caches and restarting PHPStorm was the solution.  I wonder why it broke in the first place though?  My project does have a decent sized directory tree and the heap size for it varies around 250-350M...not sure if that matters.

0

Please sign in to leave a comment.