Computes the class description using PhpDoc and writes it to the output.
324194
public function AddFileDescription() {
        $output = CodeSnippets\PhpDocSnippets::OPENING . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::AUTHOR, $this->placeholders) . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::COPYRIGHT, $this->placeholders) . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::LICENCE, $this->placeholders) . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::LINK, $this->placeholders) . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::SINCE, $this->placeholders) . $this->_LF .
                strtr(CodeSnippets\PhpDocSnippets::PACKAGE, $this->placeholders) . $this->_LF .
                CodeSnippets\PhpDocSnippets::CLOSING . $this->_LF;
        fwrite($this->writer, $output);
    }
715561
private function generatePhpDoc(): void
  {
    $this->codeStore->append('/**', false);

    // Generate phpdoc with short description of routine wrapper.
    $this->generatePhpDocSortDescription();

    // Generate phpdoc with long description of routine wrapper.
    $this->generatePhpDocLongDescription();

    // Generate phpDoc with parameters and descriptions of parameters.
    $this->generatePhpDocParameters();

    // Generate return parameter doc.
    $this->generatePhpDocBlockReturn();

    $this->codeStore->append(' */', false);
  }
105447
protected function generateClass()
    {
        if ($this->class != null) {
            throw new Exception("The class has already been generated");
        }

        $classBaseType = $this->getBaseTypeClass();

        $this->class = new PhpClass(
            $this->phpIdentifier,
            false,
            $classBaseType,
            null,
            false,
            $this->abstract
        );

        $constructorComment = new PhpDocComment();
        $constructorSource = '';
        $constructorParameters = array();
        $accessors = array();

        // Add base type members to constructor parameter list first and call base class constructor
        $parentMembers = $this->getBaseTypeMembers($this);
        if (!empty($parentMembers)) {
            foreach ($parentMembers as $member) {
                $type = Validator::validateType($member->getType());
                $name = Validator::validateAttribute($member->getName());

                if (!$member->getNullable()) {
                    $constructorComment->addParam(PhpDocElementFactory::getParam($type, $name, ''));
                    $constructorParameters[$name] = Validator::validateTypeHint($type);
                }
            }
            $constructorSource .= '  parent::__construct(' . $this->buildParametersString($constructorParameters, false) . ');' . PHP_EOL;
        }

        // Add member variables
        foreach ($this->members as $member) {
            $type = Validator::validateType($member->getType());
            $name = Validator::validateAttribute($member->getName());
            $typeHint = Validator::validateTypeHint($type);

            $comment = new PhpDocComment();
            $comment->setVar(PhpDocElementFactory::getVar($type, $name, ''));
            $var = new PhpVariable('protected', $name, 'null', $comment);
            $this->class->addVariable($var);

            if (!$member->getNullable()) {
                if ($type == '\DateTime') {
                    if ($this->config->get('constructorParamsDefaultToNull')) {
                        $constructorSource .= '  $this->' . $name . ' = $' . $name . ' ? $' . $name . '->format(\DateTime::ATOM) : null;' . PHP_EOL;
                    } else {
                        $constructorSource .= '  $this->' . $name . ' = $' . $name . '->format(\DateTime::ATOM);' . PHP_EOL;
                    }
                } else {
                    $constructorSource .= '  $this->' . $name . ' = $' . $name . ';' . PHP_EOL;
                }
                $constructorComment->addParam(PhpDocElementFactory::getParam($type, $name, ''));
                $constructorParameters[$name] = $typeHint;
            }

            $getterComment = new PhpDocComment();
            $getterComment->setReturn(PhpDocElementFactory::getReturn($type, ''));
            if ($type == '\DateTime') {
                $getterCode = '  if ($this->' . $name . ' == null) {' . PHP_EOL
                    . '    return null;' . PHP_EOL
                    . '  } else {' . PHP_EOL
                    . '    try {' . PHP_EOL
                    . '      return new \DateTime($this->' . $name . ');' . PHP_EOL
                    . '    } catch (\Exception $e) {' . PHP_EOL
                    . '      return false;' . PHP_EOL
                    . '    }' . PHP_EOL
                    . '  }' . PHP_EOL;
            } else {
                $getterCode = '  return $this->' . $name . ';' . PHP_EOL;
            }
            $getter = new PhpFunction('public', 'get' . ucfirst($name), '', $getterCode, $getterComment);
            $accessors[] = $getter;

            $setterComment = new PhpDocComment();
            $setterComment->addParam(PhpDocElementFactory::getParam($type, $name, ''));
            $setterComment->setReturn(PhpDocElementFactory::getReturn($this->phpNamespacedIdentifier, ''));
            if ($type == '\DateTime') {
                if ($member->getNullable()) {
                    $setterCode = '  if ($' . $name . ' == null) {' . PHP_EOL
                        . '   $this->' . $name . ' = null;' . PHP_EOL
                        . '  } else {' . PHP_EOL
                        . '    $this->' . $name . ' = $' . $name . '->format(\DateTime::ATOM);' . PHP_EOL
                        . '  }' . PHP_EOL;
                } else {
                    $setterCode = '  $this->' . $name . ' = $' . $name . '->format(\DateTime::ATOM);' . PHP_EOL;
                }
            } else {
                $setterCode = '  $this->' . $name . ' = $' . $name . ';' . PHP_EOL;
            }
            $setterCode .= '  return $this;' . PHP_EOL;
            $setter = new PhpFunction(
                'public',
                'set' . ucfirst($name),
                $this->buildParametersString(
                    array($name => $typeHint),
                    true,
                    // If the type of a member is nullable we should allow passing null to the setter. If the type
                    // of the member is a class and not a primitive this is only possible if setter parameter has
                    // a default null value. We can detect whether the type is a class by checking the type hint.
                    $member->getNullable() && !empty($typeHint)
                ),
                $setterCode,
                $setterComment
            );
            $accessors[] = $setter;
        }

        $constructor = new PhpFunction(
            'public',
            '__construct',
            $this->buildParametersString(
                $constructorParameters,
                true,
                $this->config->get('constructorParamsDefaultToNull')
            ),
            $constructorSource,
            $constructorComment
        );
        $this->class->addFunction($constructor);

        foreach ($accessors as $accessor) {
            $this->class->addFunction($accessor);
        }
    }
855895
private function generatePhpDocParameters(): void
  {
    $parameters = [];
    foreach ($this->routine['phpdoc']['parameters'] as $parameter)
    {
      $mangledName = $this->nameMangler->getParameterName($parameter['parameter_name']);

      $parameters[] = ['php_name'             => '$'.$mangledName,
                       'description'          => $parameter['description'],
                       'php_type'             => $parameter['php_type'],
                       'data_type_descriptor' => $parameter['data_type_descriptor']];
    }

    $this->enhancePhpDocParameters($parameters);

    if (!empty($parameters))
    {
      // Compute the max lengths of parameter names and the PHP types of the parameters.
      $max_name_length = 0;
      $max_type_length = 0;
      foreach ($parameters as $parameter)
      {
        $max_name_length = max($max_name_length, mb_strlen($parameter['php_name']));
        $max_type_length = max($max_type_length, mb_strlen($parameter['php_type']));
      }

      $this->codeStore->append(' *', false);

      // Generate phpDoc for the parameters of the wrapper method.
      foreach ($parameters as $parameter)
      {
        $format = sprintf(' * %%-%ds %%-%ds %%-%ds %%s', mb_strlen('@param'), $max_type_length, $max_name_length);

        $lines = explode(PHP_EOL, $parameter['description'] ?? '');
        if (!empty($lines))
        {
          $line = array_shift($lines);
          $this->codeStore->append(sprintf($format, '@param', $parameter['php_type'], $parameter['php_name'], $line), false);
          foreach ($lines as $line)
          {
            $this->codeStore->append(sprintf($format, ' ', ' ', ' ', $line), false);
          }
        }
        else
        {
          $this->codeStore->append(sprintf($format, '@param', $parameter['php_type'], $parameter['php_name'], ''), false);
        }

        if ($parameter['data_type_descriptor']!==null)
        {
          $this->codeStore->append(sprintf($format, ' ', ' ', ' ', $parameter['data_type_descriptor']), false);
        }
      }
    }
  }
421197
protected void writeClassInfo(ClassInfo info) {
        Node currentNode = this.currentNode;
        Element tmp = doc.createElementNS(XML_URI, "class");
        currentNode.appendChild(tmp);
        this.currentNode = tmp;
        addAccessFlags(info);
        if (info.getName() != null)
            tmp.setAttribute( "name",
                    info.getName());
        if (info.getSignature() != null)
            tmp.setAttribute( "signature",
                    info.getSignature());
        if (info.getSupername() != null)
            tmp.setAttribute( "superclass",
                              info.getSupername());
        String[] interfaces = info.getInterfaces();
        for (int i = 0; i < interfaces.length; i++) {
            Element iface = doc.createElementNS(XML_URI, "implements");
            tmp.appendChild(iface);
            iface.setAttribute( "name", 
                    interfaces[i]);
        }
        this.currentNode = currentNode;
    }
375213
protected void processClass(ClassDoc doc) {
        defaultProcess(doc, true);
        for ( MemberDoc member : doc.fields() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.constructors() ) {
            processMember(member);
        }
        for ( MemberDoc member : doc.methods() ) {
            processMember(member);
        }
        if ( doc instanceof AnnotationTypeDoc ) {
            for ( MemberDoc member : ((AnnotationTypeDoc)doc).elements() ) {
                processMember(member);
            }
        }
    }
385162
public function generateClass()
    {
        $name = $this->identifier;

        // Generate a valid classname
        $name = Validator::validateClass($name, $this->config->get('namespaceName'));

        // uppercase the name
        $name = ucfirst($name);

        // Create the class object
        $comment = new PhpDocComment($this->description);
        $this->class = new PhpClass($name, false, $this->config->get('soapClientClass'), $comment);

        // Create the constructor
        $comment = new PhpDocComment();
        $comment->addParam(PhpDocElementFactory::getParam('string', 'wsdl', 'The wsdl file to use'));
        $comment->addParam(PhpDocElementFactory::getParam('array', 'options', 'A array of config values'));

        $source = '
  foreach (self::$classmap as $key => $value) {
    if (!isset($options[\'classmap\'][$key])) {
      $options[\'classmap\'][$key] = $value;
    }
  }' . PHP_EOL;
        $source .= '  $options = array_merge(' . var_export($this->config->get('soapClientOptions'), true) . ', $options);' . PHP_EOL;
        $source .= '  if (!$wsdl) {' . PHP_EOL;
        $source .= '    $wsdl = \'' . $this->config->get('inputFile') . '\';' . PHP_EOL;
        $source .= '  }' . PHP_EOL;
        $source .= '  parent::__construct($wsdl, $options);' . PHP_EOL;

        $function = new PhpFunction('public', '__construct', 'array $options = array(), $wsdl = null', $source, $comment);

        // Add the constructor
        $this->class->addFunction($function);

        // Generate the classmap
        $name = 'classmap';
        $comment = new PhpDocComment();
        $comment->setVar(PhpDocElementFactory::getVar('array', $name, 'The defined classes'));

        $init = array();
        foreach ($this->types as $type) {
            if ($type instanceof ComplexType) {
                $init[$type->getIdentifier()] = $this->config->get('namespaceName') . "\\" . $type->getPhpIdentifier();
            }
        }
        $var = new PhpVariable('private static', $name, var_export($init, true), $comment);

        // Add the classmap variable
        $this->class->addVariable($var);

        // Add all methods
        foreach ($this->operations as $operation) {
            $name = Validator::validateOperation($operation->getName());

            $comment = new PhpDocComment($operation->getDescription());
            $comment->setReturn(PhpDocElementFactory::getReturn($operation->getReturns(), ''));

            foreach ($operation->getParams() as $param => $hint) {
                $arr = $operation->getPhpDocParams($param, $this->types);
                $comment->addParam(PhpDocElementFactory::getParam($arr['type'], $arr['name'], $arr['desc']));
            }

            $source = '  return $this->__soapCall(\'' . $operation->getName() . '\', array(' . $operation->getParamStringNoTypeHints() . '));' . PHP_EOL;

            $paramStr = $operation->getParamString($this->types);

            $function = new PhpFunction('public', $name, $paramStr, $source, $comment);

            if ($this->class->functionExists($function->getIdentifier()) == false) {
                $this->class->addFunction($function);
            }
        }
    }
425785
public void writeClassInterface()
    {
        Record recClassInfo = this.getMainRecord();
        String strClassName = recClassInfo.getField(ClassInfo.CLASS_NAME).getString();
        String strBaseClass = recClassInfo.getField(ClassInfo.BASE_CLASS_NAME).getString();
        String strClassDesc = recClassInfo.getField(ClassInfo.CLASS_DESC).getString();
        String strClassInterface = recClassInfo.getField(ClassInfo.CLASS_IMPLEMENTS).getString();
        String implementsClass = null;
        if (((ClassInfo)recClassInfo).isARecord(false))
            implementsClass = strClassName + "Model";
        if ((implementsClass != null) && (implementsClass.length() > 0))
        {
            m_IncludeNameList.addInclude(this.getPackage(CodeType.INTERFACE), null);    // Make sure this is included
            if ((strClassInterface == null) || (strClassInterface.length() == 0))
                strClassInterface = implementsClass;
            else
                strClassInterface = implementsClass + ", " + strClassInterface;
        }
        m_IncludeNameList.addInclude(strBaseClass, null);    // Make sure this is included
    
        m_StreamOut.writeit("\n/**\n *\t" + strClassName + " - " + strClassDesc + ".\n */\n");

        if ((strClassInterface == null) || (strClassInterface.length() == 0))
            strClassInterface = "";
        else
            strClassInterface = "\n\t implements " + strClassInterface;
        String strClassType = "class";
        if ("interface".equals(recClassInfo.getField(ClassInfo.CLASS_TYPE).toString()))
            strClassType = "interface";
        String strExtends = " extends ";
        if (strBaseClass.length() == 0)
            strExtends = "";
        m_StreamOut.writeit("public " + strClassType + " " + strClassName + strExtends + strBaseClass + strClassInterface + "\n{\n");
        m_StreamOut.setTabs(+1);
    }
447568
public function generate()
    {
        $code = array();

        $body = $this->getExtraBody();
        $bodyHasOpenTag = preg_match('#(?:\s*)<\?php#', $body);
        $code[] = '<?php';
        $code[] = null;

        // Documentation.
        $doc = $this->generateDocumentation();
        if ($doc !== null) {
            $code[] = $doc;
            $code[] = null;
        }

        foreach ($this->objects as $object) {
            foreach ($object->getUses() as $use => $alias) {
                $this->addUse($use, $alias);
            }
        }

        // If there are objects in different namespaces or some objects are in a different namespace compared to the file namespace.
        if ($this->areMultipleNamespacesInFile() === true) {
            $code = array_merge($code, $this->renderObjects(true));

            $code[] = $this->getIndentation() . 'namespace ' . $this->namespace;
            $code[] = '{';
            $code[] = null;

            // Temporarily add one more level of indentation.
            $this->addIndentationLevel(1);

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }

            // Set back the indentation.
            $this->addIndentationLevel(-1);

            $code[] = $this->getIndentation() . '}';
        } else {
            if ($this->namespace !== null) {
                $code[] = $this->getIndentation() . 'namespace ' . $this->namespace . ';';
                $code[] = null;
            }

            $code = array_merge($code, $this->renderRequiredFilesLines());

            $code = array_merge($code, $this->renderUsesLines());

            $code = array_merge($code, $this->renderObjects(false));

            if ($bodyHasOpenTag > 0) {
                $code[] = '?>';
            }

            if ($this->extraBody !== null) {
                $code[] = $this->extraBody;
            }
        }

        return implode($this->getLineFeed(), $code);
    }
1041248
public function classWriter(&$doclet)
    {

        parent::HTMLWriter($doclet);

        $this->_id = 'definition';

        $rootDoc =& $this->_doclet->rootDoc();
        $phpdoctor =& $this->_doclet->phpdoctor();

        $packages =& $rootDoc->packages();
        ksort($packages);

        foreach ($packages as $packageName => $package) {

            $this->_sections[0] = array('title' => 'Overview', 'url' => 'overview-summary.html');
            $this->_sections[1] = array('title' => 'Namespace', 'url' => $package->asPath().'/package-summary.html');
            $this->_sections[2] = array('title' => 'Class', 'selected' => TRUE);
            //$this->_sections[3] = array('title' => 'Use');
            if ($phpdoctor->getOption('tree')) $this->_sections[4] = array('title' => 'Tree', 'url' => $package->asPath().'/package-tree.html');
            if ($doclet->includeSource()) $this->_sections[5] = array('title' => 'Files', 'url' => 'overview-files.html');
            $this->_sections[6] = array('title' => 'Deprecated', 'url' => 'deprecated-list.html');
            $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html');
            $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html');

            $this->_depth = $package->depth() + 1;

            $classes =& $package->allClasses();

            if ($classes) {
                ksort($classes);
                foreach ($classes as $name => $class) {

                    ob_start();

                    echo "<hr>\n\n";

                    echo '<div class="qualifiedName">', $class->qualifiedName(), "</div>\n";
                    $this->_sourceLocation($class);

                    if ($class->isInterface()) {
                        echo '<h1>Interface ', $class->name(), "</h1>\n\n";
                    } else {
                        echo '<h1>Class ', $class->name(), "</h1>\n\n";
                    }

                    echo '<pre class="tree">';
                    $result = $this->_buildTree($rootDoc, $classes[$name]);
                    echo $result[0];
                    echo "</pre>\n\n";

                    $implements =& $class->interfaces();
                    if (count($implements) > 0) {
                        echo "<dl>\n";
                        echo "<dt>All Implemented Interfaces:</dt>\n";
                        echo '<dd>';
                        foreach ($implements as $interface) {
                            echo '<a href="', str_repeat('../', $this->_depth), $interface->asPath(), '">';
                            if ($interface->packageName() != $class->packageName()) {
                                echo $interface->packageName(), '\\';
                            }
                            echo $interface->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    $traits =& $class->traits();
                    if (count($traits) > 0) {
                        echo "<dl>\n";
                        echo "<dt>All Used Traits:</dt>\n";
                        echo '<dd>';
                        foreach ($traits as $trait) {
                            echo '<a href="', str_repeat('../', $this->_depth), $trait->asPath(), '">';
                            if ($trait->packageName() != $class->packageName()) {
                                echo $trait->packageName(), '\\';
                            }
                            echo $trait->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    $subclasses = $class->subclasses();
                    if ($subclasses) {
                        echo "<dl>\n";
                        echo "<dt>All Known Subclasses:</dt>\n";
                        echo '<dd>';
                        foreach ($subclasses as $subclass) {
                            echo '<a href="', str_repeat('../', $this->_depth), $subclass->asPath(), '">';
                            if ($subclass->packageName() != $class->packageName()) {
                                echo $subclass->packageName(), '\\';
                            }
                            echo $subclass->name(), '</a> ';
                        }
                        echo "</dd>\n";
                        echo "</dl>\n\n";
                    }

                    echo "<hr>\n\n";

                    if ($class->isInterface()) {
                        echo '<p class="signature">', $class->modifiers(), ' interface <strong>', $class->name(), '</strong>';
                    } elseif ($class->isTrait()) {
                        echo '<p class="signature">', $class->modifiers(), ' trait <strong>', $class->name(), '</strong>';
                    } else {
                        echo '<p class="signature">', $class->modifiers(), ' class <strong>', $class->name(), '</strong>';
                    }
                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            echo '<br>extends <a href="', str_repeat('../', $this->_depth), $superclass->asPath(), '">', $superclass->name(), "</a>\n\n";
                        } else {
                            echo '<br>extends ', $class->superclass(), "\n\n";
                        }
                    }
                    echo "</p>\n\n";

                    $textTag =& $class->tags('@text');
                    if ($textTag) {
                        echo '<div class="comment" id="overview_description">', $this->_processInlineTags($textTag), "</div>\n\n";
                    }

                    $this->_processTags($class->tags());

                    echo "<hr>\n\n";

                    $constants =& $class->constants();
                    ksort($constants);
                    $fields =& $class->fields();
                    ksort($fields);
                    $constructor =& $class->constructor();
                    $methods =& $class->methods(TRUE);
                    ksort($methods);

                    if ($constants) {
                        echo '<table id="summary_field">', "\n";
                        echo '<tr><th colspan="2">Constant Summary</th></tr>', "\n";
                        foreach ($constants as $field) {
                            $textTag =& $field->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $field->modifiers(FALSE), ' ', $field->typeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $field->name(), '">';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</a></p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($fields) {
                        echo '<table id="summary_field">', "\n";
                        echo '<tr><th colspan="2">Field Summary</th></tr>', "\n";
                        foreach ($fields as $field) {
                            $textTag =& $field->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $field->modifiers(FALSE), ' ', $field->typeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $field->name(), '">';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</a></p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            $this->inheritFields($superclass, $rootDoc, $package);
                        }
                    }

                    if ($constructor) {
                        echo '<table id="summary_constructor">', "\n";
                        echo '<tr><th colspan="2">Constructor Summary</th></tr>', "\n";
                        $textTag =& $constructor->tags('@text');
                        echo "<tr>\n";
                        echo '<td class="type">', $constructor->modifiers(FALSE), ' ', $constructor->returnTypeAsString(), "</td>\n";
                        echo '<td class="description">';
                        echo '<p class="name"><a href="#', $constructor->name(), '()">', $constructor->name(), '</a>', $constructor->flatSignature(), '</p>';
                        if ($textTag) {
                            echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                        }
                        echo "</td>\n";
                        echo "</tr>\n";
                        echo "</table>\n\n";
                    }

                    if ($methods) {
                        echo '<table id="summary_method">', "\n";
                        echo '<tr><th colspan="2">Method Summary</th></tr>', "\n";
                        foreach ($methods as $method) {
                            $textTag =& $method->tags('@text');
                            echo "<tr>\n";
                            echo '<td class="type">', $method->modifiers(FALSE), ' ', $method->returnTypeAsString(), "</td>\n";
                            echo '<td class="description">';
                            echo '<p class="name"><a href="#', $method->name(), '()">', $method->name(), '</a>', $method->flatSignature(), '</p>';
                            if ($textTag) {
                                echo '<p class="description">', strip_tags($this->_processInlineTags($textTag, TRUE), '<a><b><strong><u><em>'), '</p>';
                            }
                            echo "</td>\n";
                            echo "</tr>\n";
                        }
                        echo "</table>\n\n";
                    }

                    if ($class->superclass()) {
                        $superclass =& $rootDoc->classNamed($class->superclass());
                        if ($superclass) {
                            $this->inheritMethods($superclass, $rootDoc, $package);
                        }
                    }

                    if ($constants) {
                        echo '<h2 id="detail_field">Constant Detail</h2>', "\n";
                        foreach ($constants as $field) {
                            $textTag =& $field->tags('@text');
                            $type =& $field->type();
                            $this->_sourceLocation($field);
                            echo '<h3 id="', $field->name(),'">', $field->name(), "</h3>\n";
                            echo '<code class="signature">', $field->modifiers(), ' ', $field->typeAsString(), ' <strong>';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</strong>';
                            if (!is_null($field->value())) echo ' = ', htmlspecialchars($field->value());
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($field->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    if ($fields) {
                        echo '<h2 id="detail_field">Field Detail</h2>', "\n";
                        foreach ($fields as $field) {
                            $textTag =& $field->tags('@text');
                            $type =& $field->type();
                            $this->_sourceLocation($field);
                            echo '<h3 id="', $field->name(),'">', $field->name(), "</h3>\n";
                            echo '<code class="signature">', $field->modifiers(), ' ', $field->typeAsString(), ' <strong>';
                            if (is_null($field->constantValue())) echo '$';
                            echo $field->name(), '</strong>';
                            if (!is_null($field->value())) echo ' = ', htmlspecialchars($field->value());
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($field->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    if ($constructor) {
                        echo '<h2 id="detail_method">Constructor Detail</h2>', "\n";
                        $textTag =& $constructor->tags('@text');
                        $this->_sourceLocation($constructor);
                        echo '<h3 id="', $constructor->name(),'()">', $constructor->name(), "</h3>\n";
                        echo '<code class="signature">', $constructor->modifiers(), ' ', $constructor->returnTypeAsString(), ' <strong>';
                        echo $constructor->name(), '</strong>', $constructor->flatSignature();
                        echo "</code>\n";
                        echo '<div class="details">', "\n";
                        if ($textTag) {
                            echo $this->_processInlineTags($textTag);
                        }
                        $this->_processTags($constructor->tags());
                        echo "</div>\n\n";
                        echo "<hr>\n\n";
                    }

                    if ($methods) {
                        echo '<h2 id="detail_method">Method Detail</h2>', "\n";
                        foreach ($methods as $method) {
                            $textTag =& $method->tags('@text');
                            $this->_sourceLocation($method);
                            echo '<h3 id="', $method->name(),'()">', $method->name(), "</h3>\n";
                            echo '<code class="signature">', $method->modifiers(), ' ', $method->returnTypeAsString(), ' <strong>';
                            echo $method->name(), '</strong>', $method->flatSignature();
                            echo "</code>\n";
                            echo '<div class="details">', "\n";
                            if ($textTag) {
                                echo $this->_processInlineTags($textTag);
                            }
                            $this->_processTags($method->tags());
                            echo "</div>\n\n";
                            echo "<hr>\n\n";
                        }
                    }

                    $this->_output = ob_get_contents();
                    ob_end_clean();

                    $this->_write($package->asPath().'/'.strtolower($class->name()).'.html', $class->name(), TRUE);
                }
            }
        }
    }
379136
function createDescription() {
    $cnt = count( $this->description );
    if( 0 >= $cnt )
      return;
    $descriptions    = null;
    foreach( $this->description as $description ) {
      $attributes    = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
      $content       = $this->_strrep( $description['value'] );
      $descriptions .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
    }
    return $descriptions;
  }
553244
private void writeClassData() {
		try (PrintStream out = new PrintStream(openResultFileOuputStream(
				resultDirectory, "classes.json"))) {
			out.println("{");

			// Add direct subclass information:
			for (Entry<Integer, ClassRecord> classEntry : this.classRecords
					.entrySet()) {
				if (classEntry.getValue().subclassCount == 0
						&& classEntry.getValue().itemCount == 0) {
					continue;
				}
				for (Integer superClass : classEntry.getValue().directSuperClasses) {
					this.classRecords.get(superClass).nonemptyDirectSubclasses
							.add(classEntry.getKey().toString());
				}
			}

			int count = 0;
			int countNoLabel = 0;
			for (Entry<Integer, ClassRecord> classEntry : this.classRecords
					.entrySet()) {
				if (classEntry.getValue().subclassCount == 0
						&& classEntry.getValue().itemCount == 0) {
					continue;
				}

				if (classEntry.getValue().label == null) {
					countNoLabel++;
				}

				if (count > 0) {
					out.println(",");
				}
				out.print("\"" + classEntry.getKey() + "\":");
				mapper.writeValue(out, classEntry.getValue());
				count++;
			}
			out.println("\n}");

			System.out.println(" Serialized information for " + count
					+ " class items.");
			System.out.println(" -- class items with missing label: "
					+ countNoLabel);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
1275927
private void createClassDeclaration() {
        builder.append("package ").append(PACKAGE_NAME).append(";").append(NEWLINE);
        builder.append("public class ").append(generatedClassSimpleName).append(" extends ").
                append(CompiledNetwork.class.getName()).append("{ ").append(NEWLINE);

        builder.append("org.drools.core.spi.InternalReadAccessor readAccessor;\n");
    }
1356852
public void writeClassInit()
    {
        Record recClassInfo = this.getMainRecord();
        String strClassName = recClassInfo.getField(ClassInfo.CLASS_NAME).getString();
        if ("interface".equals(recClassInfo.getField(ClassInfo.CLASS_TYPE).toString()))
            return;
        if (this.readThisMethod(strClassName))
            this.writeThisMethod(CodeType.THICK);
        else
            this.writeThisMethod(CodeType.THICK);
    }
51986
private function writePhpFunction(): string
    {
        $phpFunction = $this->method->getPhpDoc();
        if ($this->method->getReturnType() !== 'mixed' && $this->method->getReturnType() !== 'resource') {
            $returnType = ': ' . $this->method->getReturnType();
        } else {
            $returnType = '';
        }
        $returnStatement = '';
        if ($this->method->getReturnType() !== 'void') {
            $returnStatement = "    return \$result;\n";
        }
        $moduleName = $this->method->getModuleName();

        $phpFunction .= "function {$this->method->getFunctionName()}({$this->displayParamsWithType($this->method->getParams())}){$returnType}
{
    error_clear_last();
";

        if (!$this->method->isOverloaded()) {
            $phpFunction .= '    $result = '.$this->printFunctionCall($this->method);
        } else {
            $method = $this->method;
            $inElse = false;
            do {
                $lastParameter = $method->getParams()[count($method->getParams())-1];
                if ($inElse) {
                    $phpFunction .= ' else';
                } else {
                    $phpFunction .= '    ';
                }
                if ($lastParameter->isVariadic()) {
                    $defaultValueToString = '[]';
                } else {
                    $defaultValue = $lastParameter->getDefaultValue();
                    $defaultValueToString = $this->defaultValueToString($defaultValue);
                }
                $phpFunction .= 'if ($'.$lastParameter->getParameter().' !== '.$defaultValueToString.') {'."\n";
                $phpFunction .= '        $result = '.$this->printFunctionCall($method)."\n";
                $phpFunction .= '    }';
                $inElse = true;
                $method = $method->cloneAndRemoveAParameter();
                if (!$method->isOverloaded()) {
                    break;
                }
            } while (true);
            $phpFunction .= 'else {'."\n";
            $phpFunction .= '        $result = '.$this->printFunctionCall($method)."\n";
            $phpFunction .= '    }';
        }

        $phpFunction .= $this->generateExceptionCode($moduleName, $this->method).$returnStatement. '}

';

        return $phpFunction;
    }
356268
function class_export( $classname, array $commentData = array() ){
		echo 
		"/**\n * Auto-generated file containing class $classname";
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"\n",
		"import('PLUG.parsing.Grammar');\n",
		"\n",
		"/**\n * Auto-generated Grammar subclass";
		// unset page level doc block tags we don't want against the class
		unset (
			$commentData['author'], $commentData['version']
		);
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"class $classname extends Grammar {\n",
		"\n";
		
		// overload all non-null members
		// no way to auto-detect access level ??
		$protected = get_object_vars($this);
		unset( $protected['uindex'] );
		foreach( $protected as $var => $val ){
			if( is_null($val) ){
				continue;
			}
			echo 
			"/** @override \${$var} */\n",
			"protected \${$var} = ",var_export($val,1),";\n\n";
		}
		// end vars
		echo
		"}\n";
	}
622118
public void writeRecordClassDetail(String strRecordClass)
    {
        ClassInfo recClassInfo = (ClassInfo)this.getMainRecord();
        try   {
            this.readRecordClass(strRecordClass);
            if (m_MethodNameList.size() != 0)
                m_MethodNameList.removeAllElements();
            this.writeClassInterface();
        
            m_StreamOut.writeit("private static final long serialVersionUID = 1L;\n");

            Record recFieldData = this.getRecord(FieldData.FIELD_DATA_FILE);
            Record recFileHdr = this.getRecord(FileHdr.FILE_HDR_FILE);
            FieldIterator fieldIterator = new FieldIterator(recFileHdr, recClassInfo, recFieldData, true);
        	this.writeFieldOffsets(fieldIterator, CodeType.THICK); // Write the BaseField offsets
            this.writeKeyOffsets(CodeType.THICK);   // Write the Key offsets
        
            this.writeClassFields(CodeType.THICK);
            this.writeDefaultConstructor(strRecordClass);
            
            this.writeRecordInit();
            this.writeInit();   // Special case... zero all class fields!
        
            recFileHdr.getField(FileHdr.FILE_NAME).setString(strRecordClass);
            recFileHdr.setKeyArea(FileHdr.FILE_NAME_KEY);
            boolean bFileType = (recFileHdr.seek("="));
            if (bFileType) // Is there a file with this name?
            {
                String dBFileName = recFileHdr.getField(FileHdr.FILE_MAIN_FILENAME).getString();
                if (dBFileName.length() != 0)
                {
                    dBFileName = this.fixSQLName(dBFileName);
                    if (dBFileName.equalsIgnoreCase("NONE"))
                        dBFileName = null;
                }
                else if (recFileHdr.getField(FileHdr.TYPE).toString().indexOf("MAPPED") == -1)
                    dBFileName = strRecordClass;  // Default file name (unless mapped)

                if ((dBFileName != null) && (dBFileName.length() > 0))
                    if (!this.readThisMethod("getTableNames"))
                {
                	this.writeMethodInterface(null, "getTableNames", "String", "boolean bAddQuotes", "", "Get the table name.", null);
                	m_StreamOut.writeit("\treturn (m_tableName == null) ? Record.formatTableNames(" + this.convertNameToConstant(strRecordClass + "File") + ", bAddQuotes) : super.getTableNames(bAddQuotes);\n}\n");
                }

                String recordName = recFileHdr.getField(FileHdr.FILE_REC_CALLED).getString();    // Description of a record
                String databaseName = recFileHdr.getField(FileHdr.DATABASE_NAME).getString(); // Database name
                String strDBType = recFileHdr.getField(FileHdr.TYPE).getString(); // Is Remote file?
                if (recordName.length() != 0)   // Valid Name
                {
                    if (!this.readThisMethod("getRecordName"))
                    {
                    	this.writeMethodInterface(null, "getRecordName", "String", "void", "", "Get the name of a single record.", null);
                    	m_StreamOut.writeit("\treturn \"" + recordName + "\";\n}\n");
                    }
                }
                if (databaseName.length() > 0)
                {   // If you don't supply a database name, you better supply your own method (See DatabaseInfo).
                    if (!this.readThisMethod("getDatabaseName"))
                    {
                    	this.writeMethodInterface(null, "getDatabaseName", "String", "void", "", "Get the Database Name.", null);
                    	m_StreamOut.writeit("\treturn \"" + databaseName + "\";\n}\n");
                    }
                }
                if (strDBType.length() > 0)
                {
                    if (!this.readThisMethod("getDatabaseType"))
                    {
                    	this.writeMethodInterface(null, "getDatabaseType", "int", "void", "", "Is this a local (vs remote) file?", null);
                    	strDBType = this.fixDBType(strDBType, "DBConstants.");
                    	m_StreamOut.writeit("\treturn " + strDBType + ";\n}\n");
                    }
                }
                this.writeFileMakeViews();
            }
            else
                if (recClassInfo.getField(ClassInfo.CLASS_TYPE).getString().equalsIgnoreCase("Record"))
                    m_StreamOut.writeit("\npublic static final String " + this.convertNameToConstant(strRecordClass + "File") + " = null;\t// Screen field\n");    // Screen fields
                    

            this.writeSetupField();
            this.readRecordClass(strRecordClass); // Must re-read this record class

            if (bFileType) // Is there a file with this name?
                this.writeSetupKey(CodeType.THICK, true);
            this.writeClassMethods(CodeType.THICK);       // Write the remaining methods
            this.writeEndCode(true);
        } catch (DBException ex)   {
            ex.printStackTrace();
        }
    }