简体   繁体   中英

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.

For example:

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

Eclipse would autocomplete $this->

I found this code snippet in a framework, but I can't find any documentation about this type of 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 ):

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

And use $that

But it should work in phpStorm IDE (with @var phpdoc)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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