Generator/Render/ClassAnnotation.php
protected function renderArray(&$docblock_lines, $data, $nesting = 0, $annotation_nesting = 0) {
    $indent = str_repeat('  ', $nesting);

    foreach ($data as $key => $value) {
      if (is_numeric($key)) {
        // Numeric keys are not shown.
        $declaration_line = "{$indent}";
      }
      else {
        // Keys need to be quoted for all levels except the first level of an
        // annotation.
        if ($annotation_nesting != 0) {
          $key = '"' . $key . '"';
        }

        $declaration_line = "{$indent}{$key} = ";
      }

      if (is_string($value)) {
        $value = '"' . $value . '"';

        $declaration_line .= "{$value},";
        $docblock_lines[] = $declaration_line;
      }
      elseif (is_object($value)) {
        // Child annotation. The nesting level doesn't increase here, as the
        // child annotation class is just on the same line as the key.
        // The annotation nesting level is reset, as we are starting a new
        // annotation.
        $sub_lines = $value->render($nesting, 0);

        $declaration_line .= array_shift($sub_lines);
        $docblock_lines[] = $declaration_line;

        $docblock_lines = array_merge($docblock_lines, $sub_lines);
      }
      else {
        // Array of values. Recurse into this method.
        $declaration_line .= '{';
        $docblock_lines[] = $declaration_line;

        $this->renderArray($docblock_lines, $value, $nesting + 1, $annotation_nesting + 1);

        $docblock_lines[] = $indent . "},";
      }
    }

  }
protected function renderArray(&$docblock_lines, $data, $nesting = 0, $annotation_nesting = 0) {
    $indent = str_repeat('  ', $nesting);

    foreach ($data as $key => $value) {
      if (is_numeric($key)) {
        // Numeric keys are not shown.
        $declaration_line = "{$indent}";
      }
      else {
        // Keys need to be quoted for all levels except the first level of an
        // annotation.
        if ($annotation_nesting != 0) {
          $key = '"' . $key . '"';
        }

        $declaration_line = "{$indent}{$key} = ";
      }

      if (is_string($value)) {
        $value = '"' . $value . '"';

        $declaration_line .= "{$value},";
        $docblock_lines[] = $declaration_line;
      }
      elseif (is_object($value)) {
        // Child annotation. The nesting level doesn't increase here, as the
        // child annotation class is just on the same line as the key.
        // The annotation nesting level is reset, as we are starting a new
        // annotation.
        $sub_lines = $value->render($nesting, 0);

        $declaration_line .= array_shift($sub_lines);
        $docblock_lines[] = $declaration_line;

        $docblock_lines = array_merge($docblock_lines, $sub_lines);
      }
      else {
        // Array of values. Recurse into this method.
        $declaration_line .= '{';
        $docblock_lines[] = $declaration_line;

        $this->renderArray($docblock_lines, $value, $nesting + 1, $annotation_nesting + 1);

        $docblock_lines[] = $indent . "},";
      }
    }

  }
protected function renderArray ( & $ docblock_lines , $ data , $ nesting = 0 , $ annotation_nesting = 0 ) { $ indent = str_repeat ( '  ' , $ nesting ) ; foreach ( $ data as $ key => $ value ) { if ( is_numeric ( $ key ) ) { // Numeric keys are not shown. $ declaration_line = "{$indent}" ; } else { // Keys need to be quoted for all levels except the first level of an // annotation. if ( $ annotation_nesting != 0 ) { $ key = '"' . $ key . '"' ; } $ declaration_line = "{$indent}{$key} = " ; } if ( is_string ( $ value ) ) { $ value = '"' . $ value . '"' ; $ declaration_line .= "{$value}," ; $ docblock_lines [ ] = $ declaration_line ; } elseif ( is_object ( $ value ) ) { // Child annotation. The nesting level doesn't increase here, as the // child annotation class is just on the same line as the key. // The annotation nesting level is reset, as we are starting a new // annotation. $ sub_lines = $ value -> render ( $ nesting , 0 ) ; $ declaration_line .= array_shift ( $ sub_lines ) ; $ docblock_lines [ ] = $ declaration_line ; $ docblock_lines = array_merge ( $ docblock_lines , $ sub_lines ) ; } else { // Array of values. Recurse into this method. $ declaration_line .= '{' ; $ docblock_lines [ ] = $ declaration_line ; $ this -> renderArray ( $ docblock_lines , $ value , $ nesting + 1 , $ annotation_nesting + 1 ) ; $ docblock_lines [ ] = $ indent . "}," ; } } }
Add lines for an array of data.

@param string[] &$docblock_lines
The lines of code assembled so far. Further lines are added to this.
@param mixed $data
The array of data.
@param int $nesting
(optional) See render().
@param int $annotation_nesting
(optional) See render().
Add lines for an array of data .