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 对象?
基础教程推荐
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 使用 PDO 转义列名 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01