Autocomplete for PHP Objects with classes in PDT/Netbeans?(自动完成带有 PDT/Netbeans 类的 PHP 对象?)
问题描述
当我像这样使用 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 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自动完成带有 PDT/Netbeans 类的 PHP 对象?


基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01