Alex Rivera | Logout

NetBeans auto-completion from included file not working?

Asked 2012-04-14T20:33:03.783
12

I have a file named config.php, and i have other files includes config.php. When editing one of files, I use an object from config.php and it autocompletes name of the object. But, when i try to see functions or variables of this object (with ->), there is no auto-completion. Is there any way to make it work?

Note: I already added /* @var $myObject myType */ to config.php before the object definition. Do I have to add that line to my every file includes config.php? That doesn't seem right.

Edit: Sample added.

Directory;

  • config.php
  • index.php
  • lib/test.class.php

config.php;

<?php
define('ABSPATH', dirname(__FILE__));
include_once ABSPATH.'/lib/test.class.php';

/* @var $TestObj test */
$TestObj = new test();

// auto complete works here.
$TestObj->someFunction();
?>

index.php;

<?php
include_once 'config.php';

// here, auto completes object name
// not lists functions or variables after ->
$TestObj->someFunction();
?>

lib/test.class.php;

<?php
class test {
    public $var1;

    public function someFunction() {
        echo 'I am some function.';
        return 0;
    }
}
?>

It is working when i add /* @var $TestObj test */ to index.php but I will have a lot of files like that and there must be a better way than adding that line to all of files.

Edit
Report

1 Answer

3

From netbeans go to tools->options Go to editor selection and from code Completion select php for languages section. This will expand menu and you will see a section Code Completion for Class Methods

Set that configuration by selecting checkboxes on that section. enter image description here

I hope I understood this right. I use netbeans too and I am able auto-complete after I change my netbeans settings.

answered 2012-04-20T18:43:47.187

Your Answer