highlight() public static method

Highlights code
Deprecation: since 2.0.5 this method is not used anymore, highlight.php is used for highlighting
public static highlight ( string $code, string $language ) : string
$code string code to highlight
$language string language of the code to highlight
return string HTML of highlighted code
Esempio n. 1
0
 /**
  * @param MethodDoc $method
  * @return string
  */
 public function renderMethodSignature($method, $context = null)
 {
     $params = [];
     foreach ($method->params as $param) {
         $params[] = (empty($param->typeHint) ? '' : '<span class="signature-type">' . $this->createTypeLink($param->typeHint, $context) . '</span> ') . ($param->isPassedByReference ? '<b>&</b>' : '') . ApiMarkdown::highlight($param->name . ($param->isOptional ? ' = ' . $param->defaultValue : ''), 'php');
     }
     $definition = [];
     $definition[] = $method->visibility;
     if ($method->isAbstract) {
         $definition[] = 'abstract';
     }
     if ($method->isStatic) {
         $definition[] = 'static';
     }
     return '<span class="signature-defs">' . implode(' ', $definition) . '</span> ' . '<span class="signature-type">' . ($method->isReturnByReference ? '<b>&</b>' : '') . ($method->returnType === null ? 'void' : $this->createTypeLink($method->returnTypes, $context)) . '</span> ' . '<strong>' . $this->createSubjectLink($method, $method->name) . '</strong>' . str_replace('  ', ' ', ' ( ' . implode(', ', $params) . ' )');
 }
Esempio n. 2
0
    </div>

    <table class="detail-table table table-striped table-bordered table-hover">
        <tr><td colspan="3" class="signature"><?php 
    echo $renderer->renderMethodSignature($method, $type);
    ?>
</td></tr>
        <?php 
    if (!empty($method->params) || !empty($method->return) || !empty($method->exceptions)) {
        ?>
            <?php 
        foreach ($method->params as $param) {
            ?>
                <tr>
                  <td class="param-name-col"><?php 
            echo ApiMarkdown::highlight($param->name, 'php');
            ?>
</td>
                  <td class="param-type-col"><?php 
            echo $renderer->createTypeLink($param->types);
            ?>
</td>
                  <td class="param-desc-col"><?php 
            echo ApiMarkdown::process($param->description, $type);
            ?>
</td>
                </tr>
            <?php 
        }
        ?>
            <?php 
Esempio n. 3
0
 /**
  * @param MethodDoc $method
  * @return string
  */
 public function renderMethodSignature($method)
 {
     $params = [];
     foreach ($method->params as $param) {
         $params[] = (empty($param->typeHint) ? '' : $param->typeHint . ' ') . ($param->isPassedByReference ? '<b>&</b>' : '') . $param->name . ($param->isOptional ? ' = ' . $param->defaultValue : '');
     }
     return ($method->isReturnByReference ? '<b>&</b>' : '') . ($method->returnType === null ? 'void' : $this->createTypeLink($method->returnTypes)) . ' <strong>' . $this->createSubjectLink($method, $method->name) . '</strong>' . ApiMarkdown::highlight(str_replace('  ', ' ', '( ' . implode(', ', $params) . ' )'), 'php');
 }