NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Code completion - phpdoc @property and @property-read


Joined: 27 Apr 2007
Posts: 72
Reply with quote
Hello

Is it possible to implement code completion for @property and @property-read?
Code:


/**
 * @property string name
 * @property-read int id
 * @property Orders orders
*/
class Class extends Object {
  public function __get() {
  ...
  }

  public function __set() {
  ...
  }
}

$obj = new Class()
$a = $obj->... (IDE gives hints: name, id, orders)

Thanks for reply!
View user's profileFind all posts by sirjardaSend private message
Guru master

Joined: 05 Jul 2004
Posts: 659
Location: Belgium
Reply with quote
PhpED has support for these since quite some time.
The reason it doesn't work for you is because the "official syntax" for them is to use php-variable syntax for the property name, like so:
Code:
/**
 * @property string $name
 * @property-read int $id
 * @property Orders $orders
*/


Have a good one!
View user's profileFind all posts by BlizzSend private messageVisit poster's website


Joined: 27 Apr 2007
Posts: 72
Reply with quote
Blizz wrote:
PhpED has support for these since quite some time.
The reason it doesn't work for you is because the "official syntax" for them is to use php-variable syntax for the property name, like so:
Code:
/**
 * @property string $name
 * @property-read int $id
 * @property Orders $orders
*/


Have a good one!


Hi Blizz, thanks. It was just a typo in this forum, I am using official syntax with '$' befeor names.
And YES! you are rigth, code hinting is working in this example.
But what is not working:

Code:

/**
* @property width
*/
class Class {
}

class Another extends Class {
   public function test() {
        $this-> ... no hinting here
   }
}


Is there some workaround?
View user's profileFind all posts by sirjardaSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Quote:
But what is not working:


Hmm, why do you ignore Blizz then?

This is wrong:
/**
* @property width
*/

This is correct:
/**
* @property $width
*/

for further details please read this
http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.property.pkg.html

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 03 Mar 2008
Posts: 7
Reply with quote
Please look at stackoverflow.com search for "cakephp code completion ide" and pick the first result.
Here i have described how to use @property-read to get Autocompletion working for $this.
Only detail is that the methods of the last class in the chain are not listed at the top of the list.

Example

When i want to call $this->Project->Country->getCountryName($countryId), then i would like
the top of the list to show methods for the Country class when i type $this->Project->Country->.

Is there anyway to achieve this ?
View user's profileFind all posts by sharkenSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
I'm not sure what you wanted me to find at stackoverflow.
Seems you want nested properties and calls to be accessible. No problem.
For the sake of demonstrating how it works in PhpED, see screenshots below.

First you have to define "virtual" property using supported syntax,
...and it will be picked in code completion:


After the property is entered, you can use it further, for example in nested calls like shown here:

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Code completion - phpdoc @property and @property-read
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic