getPosition() public method

Find the position of the parameter, left to right, starting at zero.
public getPosition ( ) : integer
return integer
Esempio n. 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);
 }
 /**
  * {@inheritDoc}
  */
 public function getPosition()
 {
     return $this->betterReflectionParameter->getPosition();
 }