I would like to describe a "foreach" loop with javadoc.

Maybe like this ??

<?php 
/**
 * @var array $rowset
 * @var \MyClass $row
 */
foreach($rowset as $row){

}

could you validate my syntax ?

有帮助吗?

解决方案

I suspect you only want to provide type hints to your PHP IDE rather than build HTML documentation. In that case you want variable type annotations:

/* @var $rowset array */
/* @var $row \MyClass */

Please note that it's a different feature than docblocks used by javadoc clones. Main differences are:

  • Start with /* rather than /**
  • Argument order is swapped
  • Used in different context (@var docblock precedes a property definition, @var variable type precedes a regular variable usage)
  • Aimed at IDEs rather than API documentation generators

They are supported by at least NetBeans and PhpStorm.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top