NetBeans。代码完成。 PHP
我使用这样的东西:
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 */
更新: 我想在 index.tpl
的代码完成中查看我在 index.php
中使用的属性 属性不应在 view php
中作为属性列出
I use something like this:
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?
I know that something like this are allowed in ZendFramework plugin
Maybe I can add it with my framework?
some other html */
UPD:
I want to see properties which I used in index.php
in code completion in index.tpl
Properties should not be listed in view php
as properties
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是行不通的:
有几个原因。首先,文档块以
/**
开头,而不仅仅是/*
。此外,您还声明$this
为Viewer
的实例,但实际的类名称是View
。这不匹配,因此您将不会获得任何代码完成(或者至少不会获得预期的代码完成)。所以你应该使用:
另外,如果你想访问属性,你应该声明它们。这是 Netbeans 了解这些属性的唯一方法。
我还没有测试在文档块中为
$this
指定一个类是否真的有效。This won't work:
And there are a few reasons for that. First, docblocks start with
/**
not just/*
. Also you declare$this
to be an instance ofViewer
, but the actual class name isView
. That doesn't match, so you won't get any code completion (or at least not the expected code completion).So you should use:
Also, if you want access to properties, you should declare them. That's the only way Netbeans will know about the properties.
I have not tested if specifying a class for
$this
in a docblock will actually work.