getDefaultValueAsString() public méthode

Get the default value represented as a string.
public getDefaultValueAsString ( ) : string
Résultat string
Exemple #1
0
 public function formatParameter(ReflectionMethod $method, ReflectionParameter $parameter)
 {
     $code = '$' . $parameter->getName();
     $text = '';
     if ($parameter->isDefaultValueAvailable()) {
         if ($parameter->isDefaultValueConstant()) {
             $code .= ' = ' . $parameter->getDefaultValueConstantName();
         }
         $code .= ' = ' . $parameter->getDefaultValueAsString();
     }
     if ($parameter->isPassedByReference()) {
         $code = '&' . $code;
     }
     $doc = $this->getMethodDocBlock($method);
     $paramTags = $doc->getTagsByName('param');
     $type = 'mixed';
     /** @var \phpDocumentor\Reflection\DocBlock\Tag\ParamTag $paramTag */
     foreach ($paramTags as $paramTag) {
         if ($paramTag->getVariableName() === '$' . $parameter->getName() && $paramTag->getDescription() !== '') {
             $text .= ' — ' . $paramTag->getDescription();
             $type = $paramTag->getType();
         }
     }
     return sprintf('%d. `%s` — `%s` %s', $parameter->getPosition() + 1, $code, $type, $text);
 }