X

An Oracle blog about NetBeans for PHP

Code Completion for Namespaces - part I

Guest Author

This is brief overview how to use code completion for namespaced elements in NetBeans 6.8.
Namespaced elements are resolved according  name resolution rules.

See examples for namespace name definitions that are important for resolution rules:

// Fully qualified name
$c = new \\my\\name\\ExampleClass();
// Qualified name
$c = new name\\ExampleClass();
// Unqualified name
$c = new ExampleClass();

Now we have 3 ways how to create new instance of class ExampleClass. Let's look how to harness code completion to generate all of them.

Fully qualified name

Simply begin with a namespace
separator after new keyword (e.g. new \\Exam), choose from the list of proposals and press enter. 

fully qualified name proposals

As a result:

fully qualified name result

Unqualified name

 The same as for fully qualified name - just omit namespace separator at the beginning (e.g. new Exam).

qualified name proposal

As a result:

qulified name result

Qualified name

Begin with a sub-namespace name (whereas code completion can be used here also ) followed with namespace separator after new keyword (e.g. new name\\Exam), choose from the list of proposals and press enter. 

qualified name proposal

As a result:

qualified name result

As mentioned above, for sub-namespace name can be used code completion too.

namespace name proposal

For e.g. new name\\test\\Exam can be used code completion 3 times: name, test, Exam.

Join the discussion

Comments ( 4 )
  • blostutalk Monday, August 10, 2009

    DO we have any other version of NetBeans. this NetBeans 6.8 is getting trouble often.

    Regards,

    stutalk.com


  • radek Monday, August 10, 2009

    to blostutalk:

    NetBeans 6.8 is in development phase, relase is planned for Fall 2009, but using it and reporting bug is very helpful for us and help us make the IDE better.

    Latest stable version is 6.7.1:

    http://www.netbeans.org/downloads/index.html


  • guest Monday, August 10, 2009

    to blostutalk:

    BTW: could you report the mentioned problems, thanks


  • Vitex Monday, August 10, 2009

    Diky! Nice work


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.