当我像这样使用 new 定义一个类的对象时
When I define an object of a class using new like this
$blah = new Whatever();
我得到了 $blah 的自动完成.但是当我将 $blah 作为函数参数时我该怎么做?如果没有自动完成,我是不完整的.
I get autocomplete for $blah. But how do I do it when I have $blah as a function parameter? Without autocomplete I am incomplete.
编辑:如果它在包含中并且 PDT 或 Netbeans 无法弄清楚,我该怎么做? 有没有办法在其中声明变量的类型PHP?
Edit: How do I do it if it's in an include and PDT or Netbeans can't figure it out? Is there any way to declare types for variables in PHP?
第一个注释中的方法称为类型提示",但您应该明智地使用它.更好的解决方案是 phpDoc.
Method in first comment is called "type hinting", but you should use that wisely. Better solution is phpDoc.
/**
* Some description of function behaviour.
*
* @param Whatever $blah
*/
public function myFunction($blah)
{
$blah->
// Now $blah is Whatever object, autocompletion will work.
}
您也可以使用内联的 phpDoc 注释,它的作用完全相同.
You can also use an inline phpDoc comment which does exactly the same thing.
public function myFunction($blah)
{
/* @var $blah Whatever */
$blah->
// Now $blah is Whatever object, autocompletion will work.
}
这篇关于自动完成带有 PDT/Netbeans 类的 PHP 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!