PhpCsFixer\DocBlock\Annotation::setTypes PHP Method

setTypes() public method

Set the types associated with this annotation.
public setTypes ( array $types )
$types array
    public function setTypes(array $types)
    {
        $pattern = '/' . preg_quote($this->getTypesContent()) . '/';
        $this->lines[0]->setContent(preg_replace($pattern, implode('|', $types), $this->lines[0]->getContent(), 1));
        $this->typesContent = null;
    }

Usage Example

 /**
  * Fix the types at the given line.
  *
  * We must be super careful not to modify parts of words.
  *
  * This will be nicely handled behind the scenes for us by the annotation class.
  *
  * @param Annotation $annotation
  */
 private function fixTypes(Annotation $annotation)
 {
     $types = $annotation->getTypes();
     $new = $this->normalizeTypes($types);
     if ($types !== $new) {
         $annotation->setTypes($new);
     }
 }
All Usage Examples Of PhpCsFixer\DocBlock\Annotation::setTypes