yii\apidoc\helpers\PrettyPrinter::getRepresentationOfValue PHP Method

getRepresentationOfValue() public static method

Returns a simple human readable output for a value.
public static getRepresentationOfValue ( PhpParser\Node\Expr $value ) : string
$value PhpParser\Node\Expr The value node as provided by PHP-Parser.
return string
    public static function getRepresentationOfValue(Expr $value)
    {
        if ($value === null) {
            return '';
        }
        $printer = new static();
        return $printer->prettyPrintExpr($value);
    }

Usage Example

Example #1
0
 /**
  * @param \phpDocumentor\Reflection\ClassReflector\PropertyReflector $reflector
  * @param Context                                                    $context
  * @param array                                                      $config
  */
 public function __construct($reflector = null, $context = null, $config = [])
 {
     parent::__construct($reflector, $context, $config);
     if ($reflector === null) {
         return;
     }
     $this->visibility = $reflector->getVisibility();
     $this->isStatic = $reflector->isStatic();
     // bypass $reflector->getDefault() for short array syntax
     if ($reflector->getNode()->default) {
         $this->defaultValue = PrettyPrinter::getRepresentationOfValue($reflector->getNode()->default);
     }
     $hasInheritdoc = false;
     foreach ($this->tags as $tag) {
         if ($tag->getName() === 'inheritdoc') {
             $hasInheritdoc = true;
         }
         if ($tag instanceof VarTag) {
             $this->type = $tag->getType();
             $this->types = $tag->getTypes();
             $this->description = ucfirst($tag->getDescription());
             if (($pos = strpos($this->description, '.')) !== false) {
                 $this->shortDescription = substr($this->description, 0, $pos + 1);
             } else {
                 $this->shortDescription = $this->description;
             }
         }
     }
     if (empty($this->shortDescription) && $context !== null && !$hasInheritdoc) {
         $context->errors[] = ['line' => $this->startLine, 'file' => $this->sourceFile, 'message' => "No short description for element '{$this->name}'"];
     }
 }
All Usage Examples Of yii\apidoc\helpers\PrettyPrinter::getRepresentationOfValue