NetBeans的。代码完成。 PHP

时间:2011-05-24 16:17:05

标签: php netbeans code-completion

我使用这样的东西:

index.php(entryPoint)

<?php
include 'view.php';
$view= new View;

$view->a=5;
$view->render('index.tpl');

view.php
<?

clas View{    
   public function render($file){     
        include 'templates/'.$file;
   }
}

templates/index.tpl


<?php /* @var $this View */?>
//some html
<?php $this->| ?> /*I want to see "a" incode completion here
                  How it is possible?

我知道ZendFramework插件允许这样的东西 也许我可以用我的框架添加它?    其他一些html * /

UPD: 我希望在index.php中看到index.tpl在代码完成中使用的属性 属性不应在view php中列为属性

1 个答案:

答案 0 :(得分:2)

这不起作用:

<?php /* @var $this Viewer */?>

这有几个原因。首先,docblock以/**开头而不仅仅是/*。您还要将$this声明为Viewer的实例,但实际的类名称为View。这不符合,所以你不会得到任何代码完成(或至少不是预期的代码完成)。 所以你应该使用:

<?php /** @var $this View */?>

此外,如果要访问属性,则应声明它们。这是Netbeans了解房产的唯一方式。

我没有测试过在docblock中为$this指定一个类是否真的有效。

相关问题