Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Problem with code assist for arrays
Problem with code assist for arrays [message #1393128] Thu, 03 July 2014 09:26 Go to next message
Žilvinas Žaltiena is currently offline Žilvinas ŽaltienaFriend
Messages: 4
Registered: July 2014
Junior Member
I am a bit puzzled with array hinting for code assist. Consider this synthetic example :
class foo {
	public $value;	
}

class bar {
	public $foos;
	
	/**
	 * @return foo[]
	 */
	public function getHintedFoos(){
		return $this->foo;
	}
	
	public function getUnhintedFoos(){
		return $this->foo;
	}	
}

$obj_bar = new bar();

$obj_bar->getHintedFoos()[0]->		// WORKS: code assist uses @return as hint
$obj_bar->getUnhintedFoos()[0]->	// DOES NOT WORK, OBVIOUSLY: code assist has no clue what is returned

/* @var $single_foo foo */
$single_foo = $obj_bar->getUnhintedFoos();
$single_foo->						// WORKS: code assist uses @var as hint 

/* @var $array_foos foo[] */
$array_foos = $obj_bar->getUnhintedFoos();
$array_foos[0]->					// DOES NOT WORK, WHY???


Is there a bug in PDT (3.3.0.201406110111) or are my hints in wrong syntax?
Re: Problem with code assist for arrays [message #1393759 is a reply to message #1393128] Fri, 04 July 2014 08:19 Go to previous messageGo to next message
Dawid Pakula is currently offline Dawid PakulaFriend
Messages: 290
Registered: March 2013
Senior Member
First problem, use php doc for $foo field:
Change from
class bar {
	public $foos;
...


to
class bar {
    /**
     * @var foo[]
     */
    public $foo;
...


Second, pdt vardoc doesn't support array hint. You can create feature request on bugzilla: bugs.eclipse.org


Re: Problem with code assist for arrays [message #1393884 is a reply to message #1393759] Fri, 04 July 2014 12:22 Go to previous messageGo to next message
Žilvinas Žaltiena is currently offline Žilvinas ŽaltienaFriend
Messages: 4
Registered: July 2014
Junior Member
Dawid Pakula wrote on Fri, 04 July 2014 04:19
First problem, use php doc for $foo field


I can't. Foo and bar lives somewhere deep in a large 3rd party framework, and arrays of foo (sometimes even baz) instances are returned via the same factory method. My idea was to make hinting by using vardoc as I know excatly what I will get, but unfortunately arrays are not supported.

[Updated on: Fri, 04 July 2014 12:22]

Report message to a moderator

Re: Problem with code assist for arrays [message #1395071 is a reply to message #1393884] Sun, 06 July 2014 09:58 Go to previous message
Dawid Pakula is currently offline Dawid PakulaFriend
Messages: 290
Registered: March 2013
Senior Member
I reported this problem on bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=438972

Previous Topic:Eclipse 3.8 on Xubuntu 14.04 PHP development crash with no reason
Next Topic:how to configure php eclipse to use apache
Goto Forum:
  


Current Time: Fri Oct 04 02:49:26 GMT 2024

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

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

Back to the top