Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » php content assist autocompletion help(make content assist work when used on a global)
php content assist autocompletion help [message #635205] Tue, 26 October 2010 00:42 Go to next message
Ben K is currently offline Ben K
Messages: 27
Registered: July 2009
Junior Member
is there anyway i can 'teach' content assist autocompletion in eclipse pdt what object my variable contains?

autocompletion stops working if i am in a function (with object passed as a parameter) or if my object is stored in a superglobal such as :

$_SESSION['user_db_handler']

i.e.
$smarty = new Smarty();
$smarty-> (this will autocomplete with ctrl-space)
$test_one =& $smarty;
$_SESSION['smarty'] =& $smarty;
$test_one-> (this will autocomplete)
$_SESSION['smarty' ->( this will not autocomplete)
test($smarty);

function test(&$smarty){
$smarty-> (this will not autocomplete)
}


anyone know how i can tell the autocompleter that my $_SESSION['smarty'] or $_SESSION['db'] holds a database object so autocomplete works?
thanks in advance!



Re: php content assist autocompletion help [message #639072 is a reply to message #635205] Mon, 15 November 2010 08:23 Go to previous messageGo to next message
True is currently offline True
Messages: 3
Registered: July 2009
Junior Member
Use a strict type for the $smarty parameter:

function test (Smarty &$smarty)
{
$smarty-> (this should autocomplete)
}


Or use the phpdoc hints:

/**
*
* @param $smarty Smarty
*/
function test (&$smarty)
{
$smarty-> (this should autocomplete too)
}


Another phpdoc hint will help for general type issues, but you have to use simple variables -> there are no hints for arrays at all (except $GLOBALS which accesses the simple global vars)

Or use the phpdoc hints:

/**
*
* @param Smarty $smarty
*/
function test (&$smarty)
{
$smarty-> (this should autocomplete too)

/* @var $db DB */
$db = &$_SESSION["db"];
}


The @var phpdoc declaration is the only one, which type is defined after the variable name
Re: php content assist autocompletion help [message #639289 is a reply to message #639072] Mon, 15 November 2010 22:35 Go to previous message
Ben K is currently offline Ben K
Messages: 27
Registered: July 2009
Junior Member
Thanks that's awesome, exactly what i needed!
Previous Topic:RCP & Java with XML Editing feature
Next Topic:Indent more than one line
Goto Forum:
  


Current Time: Sat Oct 25 02:56:50 GMT 2014

Powered by FUDForum. Page generated in 0.04607 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software