Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top