[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.pdt] Re: phpDoc @property tag not working.

Hi Runar,

It's funny that you raise this issue today, because I have committed the fixes this morning. for more details see this Bugzilla issue (Bug #235108 - [GoalEvaluator] Evaluate __call() __ get() functions and variables) https://bugs.eclipse.org/bugs/show_bug.cgi?id=235108

Eclipse PDT now supports both @property and @method tags that indicate magic fields and methods.

I will appreciate it if you can check next nightly build and see if this answers your requirements.

Regards,

Runar B. Olsen wrote:

Hi,

Lets say you have a class that acts as a registry and that contains the magic methods __get($var) and __set($var, $value); Now for most of the time you cannot be sure what type of variable __get will return but you do know that __get('foo'); always will return a instance of the Foo class. According to phpDoc (http://preview.tinyurl.com/2fxl57) you can add the @property doc tag for the class defining that the property $foo of the class Registery is a instance of Foo, but PDT does not seem to take this into account when it comes to auto completing. Is this something that will be included in a later release?

Example:

<?php

/**
  * @property Foo $foo
  */
class Registry {
     private $datastore = array();

     public function __get($var) {
         if(array_key_exists($var, $this->datastore) {
             return $this->datastore[$var];
         }
         return false;
     }
}

class Foo {
     public function bar()
     {
         echo 'FooBar!';
     }
}

$reg = new Registry();

// There is no foo in the auto complete list here
$foo = $reg->foo;
// Typing in $foo-> does not tell me about the bar method.