Class yii\apidoc\helpers\PrettyPrinter
Inheritance | yii\apidoc\helpers\PrettyPrinter » PhpParser\PrettyPrinter\Standard |
---|---|
Available since version | 2.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
Method | Description | Defined By |
---|---|---|
getRepresentationOfValue() | Returns a simple human readable output for a value. | yii\apidoc\helpers\PrettyPrinter |
Protected Methods
Method | Description | Defined By |
---|---|---|
pMaybeMultiline() | yii\apidoc\helpers\PrettyPrinter | |
pSingleQuotedString() | yii\apidoc\helpers\PrettyPrinter |
Method Details
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);
}
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;
}
}
protected string pSingleQuotedString ( string $string ) | ||
$string | string |
protected function pSingleQuotedString(string $string) {
return '\'' . preg_replace("/'|\\\\(?=[\\\\']|$)/", '\\\\$0', $string) . '\'';
}