|
Re: Code completion... [message #80883 is a reply to message #80878] |
Mon, 29 September 2008 00:08 |
Eclipse User |
|
|
|
Originally posted by: eclipsenews.20.epm.spamgourmet.com
The only way PDT can tell what type $this->MyModel is, is if you write a
PHPDoc comment.
Given that it's cakephp and the mymodel object is created via some
hidden runtime voodoo, there's no way for PDT to tell what type it is.
You can try adding a doc comment identifying it to your controller,
hopefully cake will play nice with that.
Eugen wrote:
> I don't know if this was brought up before, or what its referred to, but
> I work with cakePHP a lot, and I run into a problem that I don't get
> code completion on custom Models when I reference them from the controller.
> For example I will have my userModel.php
>
> class MyModel extends AppModel {
> var $name;
>
> }
>
> and in my userController.php I will have
> class UserController extends AppController {
> echo $this->MyModel->save($this->form(data);
>
> }
>
>
> $this->MyModel->[code completion jumps in]
> does anyone have a glue how to make this work?
>
|
|
|
Re: Code completion... [message #83387 is a reply to message #80883] |
Tue, 11 November 2008 12:05 |
Eclipse User |
|
|
|
Originally posted by: michael.zend.com
Not exactly. If you have an assignment to this variable in your class
constructor it will be taken into account also.
For example:
class B {
function foo() {
}
}
class A {
var $v;
function __construct() {
$this->v = new B();
}
}
$a = new A();
$a->v->foo(); // here foo() is proposed by Code Assist
"Tom Walter" <eclipsenews.20.epm@spamgourmet.com> wrote in message
news:48E01C8B.3060807@spamgourmet.com...
> The only way PDT can tell what type $this->MyModel is, is if you write a
> PHPDoc comment.
>
> Given that it's cakephp and the mymodel object is created via some hidden
> runtime voodoo, there's no way for PDT to tell what type it is.
>
> You can try adding a doc comment identifying it to your controller,
> hopefully cake will play nice with that.
>
>
> Eugen wrote:
>> I don't know if this was brought up before, or what its referred to, but
>> I work with cakePHP a lot, and I run into a problem that I don't get code
>> completion on custom Models when I reference them from the controller.
>> For example I will have my userModel.php
>>
>> class MyModel extends AppModel {
>> var $name;
>>
>> }
>>
>> and in my userController.php I will have
>> class UserController extends AppController {
>> echo $this->MyModel->save($this->form(data);
>>
>> }
>>
>>
>> $this->MyModel->[code completion jumps in]
>> does anyone have a glue how to make this work?
>>
|
|
|
|
Re: Code completion... [message #83672 is a reply to message #83658] |
Thu, 13 November 2008 14:06 |
Eclipse User |
|
|
|
Originally posted by: michael.zend.com
Such examples can become a use cases for our Type Inference engine that can
be improved.
Thanks!
"Romain Riviere" <romain.riviere@gmail.com> wrote in message
news:2c5ced46408675a79299ca9818d638e2$1@www.eclipse.org...
> Hello there,
>
> Michael Spector wrote:
>
>> Not exactly. If you have an assignment to this variable in your class
>> constructor it will be taken into account also.
>> For example:
>
>> class B {
>> function foo() {
>> }
>> }
>
>> class A {
>> var $v;
>> function __construct() {
>> $this->v = new B();
>> }
>> }
>
>> $a = new A();
>> $a->v->foo(); // here foo() is proposed by Code Assist
>
> This is fine as long as you are not using Singletons. Consider this :
>
> class B {
> private $instance ;
> public static function GetInstance() {
> if(empty(self::$instance)) {
> self::$instance = new B ; }
> return self::$instance ;
> }
> function foo() {
> }
> }
>
> class A {
> var $v;
> function __construct() {
> $this->v = B::GetInstance();
> }
> }
>
> $a = new A();
> $a->v->foo(); // No Code Assist here
>
> In that case, adding a PHPDoc block for "var $v" is the only way (AFAIK)
> to get Code Assist to work.
> Adding a PHPDoc block to the GetInstance static method in order to specify
> the return type also helps but only inside the class context.
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04656 seconds