Php 是否可以在项目中的所有方法和类上获得代码完成?
我有一个项目是某种MVC模式。在boot类中,我创建了控制器的实例,它创建了视图和模型的实例。但模型是用loadModel方法加载的。然后所有控制器扩展控制器类。是这样的:Php 是否可以在项目中的所有方法和类上获得代码完成?,php,netbeans,Php,Netbeans,我有一个项目是某种MVC模式。在boot类中,我创建了控制器的实例,它创建了视图和模型的实例。但模型是用loadModel方法加载的。然后所有控制器扩展控制器类。是这样的: class boot{ function __construct(){ //some code... exploding url etc require 'controllers/'.$url[0].".php"; $this->controller = new $url[0]; $
class boot{
function __construct(){
//some code... exploding url etc
require 'controllers/'.$url[0].".php";
$this->controller = new $url[0];
$this->controller->loadModel($url[0]);
//.....
}
}
class controller{
function __construct(){
$this->view = new view();
}
function loadModel($name){
$modelName = $name."_model"
//....
$this->model = new $modelName();
//....
}
}
class model{
// some code
}
class view{
// some code
}
因此,我制作了新的控制器和模型:
class test_model extends model{
function __construct(){
parent::__construct()
}
function alabala(){
some code...
}
function afdfa(){
some code...
}
function asdfadf(){
some code...
}
}
class test extends controller{
function __construct(){
parent::__construct()
}
->here is the problem<-
$this->model->no methods suggestions
}
class-test\u模型扩展模型{
函数_u构造(){
父项::_构造()
}
函数alabala(){
一些代码。。。
}
函数afdfa(){
一些代码。。。
}
函数asdfadf(){
一些代码。。。
}
}
类测试扩展控制器{
函数_u构造(){
父项::_构造()
}
->以下是问题模型->无方法建议
}
NetBeans不建议使用test\u model
中的任何方法
PhpDesigner 7和PhpDesigner 8建议所有方法形成任何模型类。我如何设置NetBeans以提供项目中所有类别的所有方法?问题是IDE在计算属性类型方面只会走这么远。有两种解决方法:
class boot {
/* @var $model test_model */
protected $model;
....
}
想想看,这可能只是/*$var test_model*/
;我不确定,因为我总是使用自定义getter:
class test extends controller {
public function __construct() {
parent::__construct()
}
public function anotherMethod() {
$this->getTestMode->will offer model suggestions...
}
/**
* Get test_model
*
* @return test_model
*/
public function getTestModel() {
return $this->model;
}
}
是“phpdoc”注释通知IDE返回的类的类型,它自动选择要提供的类方法和属性的正确集合
旁白:总是指定访问级别是一种很好的方式,即方法和属性是
公共的
,受保护的
还是私有的
。诚然,默认情况下它们是公共的
,但是如果没有这个说明符,它们看起来更像是旧式的PHP4,而新的样式指南(例如PSR-x)采用了显式的形式。这可能会有所帮助,它是专门针对Zend Framework的,但可能对您有用。