开发者

bind Dreamweaver for a particular code hint

开发者 https://www.devze.com 2023-03-07 21:14 出处:网络
I have this function: function Q() { return new Q(); } Basically with it I Can do Q()->methods(); Without it i couldn\'t have done it in one line but using the new:

I have this function:

function Q() {
 return new Q();
}

Basically with it I Can do Q()->methods();

Without it i couldn't have done it in one line but using the new:

$var = new Q();
$var->methods();

Now my question is: is there a way to bind the function Q() as it was new Q() to have the classic code hint displayed?

Note I can referer to a more generic bind (consider I am using a Registry Pattern/Service Container), example:

function Q($which) {
 if ($which==1)
  return new FirstObj();
 else
  开发者_如何学Goreturn new SecondObj();
}

Q(1)->firstClassMethod();
Q(2)->secondClassMethod();
Q('otherClass')->otherClassMethod();


Unfortunately, no, you won't get code hints from Dreamweaver for this type of code. Dreamweaver does not execute the PHP code in order to determine what code hints to provide, as it would need to do for this type of "dynamic" object creation especially once you get to objects that themselves have different methods exposed based on what is passed into their constructors (think mixins).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号