简体   繁体   English

如何在类之外使用phpdocs?

[英]How to use phpdocs outside of classes?

I recently discovered, that you can have phpdocs outside of classes and your IDE (like Eclipse) would autocomplete it. 我最近发现,您可以在类之外使用phpdocs,而您的IDE(例如Eclipse)将自动完成它。

For example: 例如:

<?php /* @var $this Controller */ ?> <div><?php echo $this->app()->name; ?></div>

Eclipse would autocomplete $this-> Eclipse会自动完成$this->

I found this code snippet in a framework, but I can't find any documentation about this type of phpdoc. 我在框架中找到了此代码段,但找不到有关此类phpdoc的任何文档。 Has anyone a link for me? 有没有人给我链接? I didn't know, this was possible? 我不知道,这可能吗?

Thanks in advance! 提前致谢!

In eclipce I know this way ( Eclipse completions - @var (PHPDoc) question ): 在eclipce中,我知道这种方式( Eclipse完成- @var (PHPDoc)问题 ):

$that = $this;
if (false) $that = new Controller();

And use $that 并使用$ that

But it should work in phpStorm IDE (with @var phpdoc) 但是它应该可以在phpStorm IDE中工作(使用@var phpdoc)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM