This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 169088 - Better PHP code completion for dynamic properties and nested objects
Summary: Better PHP code completion for dynamic properties and nested objects
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 2 votes (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-24 02:11 UTC by markeb
Modified: 2017-02-17 15:44 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description markeb 2009-07-24 02:11:08 UTC
I would like to see better nested object code completion for PHP. What I mean by "nested" objects is where an object has
a property that is an object.

Take the following example:

$obj1 = new stdClass();
$obj1->obj2 = new stdClass();
$obj1->obj2->str1 = 'Test'; // no code completion (expected: $obj1-> should suggest "obj2")
echo $obj1->obj2->str1; // no code completion (expected: $obj1->obj2-> should suggest "str1")

Lastly, I've also noticed that code like the following works fine with the autocompletion:

// FILE: File.php
class Class1
{
	var $subClass;
	function Class1()
	{
		$this->subClass = new Class2();
	}
}
class Class2 extends Class1
{
	var $str = 'test';
}
$obj = new Class1();
echo $obj->subClass->str; // autocompletes fine

BUT, the above will have autocomplete issues when the two class definitions are moved to a separate file, as follows:

// FILE: File1.php
class Class1
{
	var $subClass;
	function Class1()
	{
		$this->subClass = new Class2();
	}
}
class Class2 extends Class1
{
	var $str = 'test';
}

// FILE: File2.php
$obj = new Class1();
echo $obj->subClass->str; // autocompletes for $obj->, but $obj->subClass-> has no suggestions

Thanks!
Comment 1 Tomasz Slota 2010-02-10 08:46:48 UTC
reassigning to default owner
Comment 2 bigredc2 2010-07-13 20:22:51 UTC
I also noticed this bug in 6.9 on mac os x pretty much the same as described in the first description. Also I thought I should note that even trying to define the property in a comment does not work

ie if I have and object that looks like this:

$obj->subclass->prop


and I try to define subclass in the comments like this

/* @var $obj->subclass SubClass */ 

this does not work either. I realize that may not have been the intention of the comment definition but I though I would give it a try and see but it doesn't work.
Comment 3 AIML_Engr 2010-07-30 14:24:33 UTC
Broken for me as well on Mac 10.6.4 with NB 6.8 or 6.9 in PHP. Also of note, when implementing interfaces, constants from the interface do not autocomplete in the implementing class. Ex:

interface Test {
  const testConst = 'test';
}  

class TestClass implements Test {
  ...
}

$test = new Test();
$constString = $test::testConst; <-- this will not autocomplete

I use this many times a day. Saves hunting down frustrating typos ;o)
Comment 4 Filip Zamboj 2010-09-15 12:29:26 UTC
batch reassigning
Comment 5 xavier83ar 2012-03-16 23:00:31 UTC
This feature was working ok for me until last update, since then (about a week ago) this stop working.
I'm using netbeans 7.1 updated, under ubuntu linux. Is there a chance of uninstall the updates? that could help me.
Comment 6 amobilia 2016-09-22 03:13:31 UTC
Reproductible in 8.2rc / Dev 201609210002
Comment 7 Xenos 2017-02-17 15:44:51 UTC
The interface showcase from Comment 3 is resolved in NB 8.2 for me.

The separated class showcase works for me on NB 8.2 (as long as you don't mess with the namespaces).

----------
But the stdClass example of Comment 1 is still broken:

$obj1 = new stdClass();
$obj1->obj2 = new stdClass();
$obj1->obj2->str1 = 'Test'; // no code completion (expected: $obj1-> should suggest "obj2")
echo $obj1->obj2->str1; // no code completion (expected: $obj1->obj2-> should suggest "str1")

I don't know if that enhancement will actually be added someday.