Class yii\apidoc\helpers\PrettyPrinter

Inheritanceyii\apidoc\helpers\PrettyPrinter » PhpParser\PrettyPrinter\Standard
Available since version2.0
Source Code https://github.com/yiisoft/yii2-apidoc/blob/master/helpers/PrettyPrinter.php

Enhances the phpDocumentor PrettyPrinter:

  • Fix for single slash becoming double in values of properties and class constants.
  • All comments in values are removed because inline comments are shifted to the next line (can be confusing).

Public Methods

Hide inherited methods

Method Description Defined By
getRepresentationOfValue() Returns a simple human readable output for a value. yii\apidoc\helpers\PrettyPrinter

Method Details

Hide inherited methods

getRepresentationOfValue() public static method
Deprecated Pretty print is handled in "phpdocumentor/reflection" library. This custom pretty printer is now injected through strategies and not directly called within "apidoc" extension.

Returns a simple human readable output for a value.

public static string getRepresentationOfValue ( \PhpParser\Node\Expr $value )
$value \PhpParser\Node\Expr

The value node as provided by PHP-Parser.

                public static function getRepresentationOfValue(Expr $value)
{
    if ($value === null) {
        return '';
    }
    $printer = new static();
    return $printer->prettyPrintExpr($value);
}

            
pMaybeMultiline() protected method

protected string pMaybeMultiline ( array $nodes, boolean $trailingComma false )
$nodes \PhpParser\NodeAbstract[]
$trailingComma boolean

                protected function pMaybeMultiline(array $nodes, bool $trailingComma = false)
{
    foreach ($nodes as $node) {
        $node->setAttribute('comments', []);
    }
    if (!$nodes) {
        return $this->pCommaSeparated($nodes);
    } else {
        return $this->pCommaSeparatedMultiline($nodes, $trailingComma) . $this->nl;
    }
}

            
pSingleQuotedString() protected method

protected string pSingleQuotedString ( string $string )
$string string

                protected function pSingleQuotedString(string $string) {
    return '\'' . preg_replace("/'|\\\\(?=[\\\\']|$)/", '\\\\$0', $string) . '\'';
}