Set the author information in doc block.

@param string $docBlock The doc block.
@param array  $authors  The authors to set in the doc block.

@return string The updated doc block.
429172
protected function setAuthors($docBlock, $authors)
    {
        $newAuthors = array_unique(array_values($authors));
        $lines      = \explode("\n", $docBlock);
        $lastAuthor = 0;
        $indention  = ' * @author     ';
        $cleaned    = [];

        foreach ($lines as $number => $line) {
            if (\strpos($line, '@author') === false) {
                continue;
            }
            $lastAuthor = $number;
            $suffix     = \trim(\substr($line, (\strpos($line, '@author') + 7)));
            $indention  = \substr($line, 0, (\strlen($line) - \strlen($suffix)));

            $index = $this->searchAuthor($line, $newAuthors);

            // Obsolete entry, remove it.
            if (false === $index) {
                $lines[$number] = null;
                $cleaned[]      = $number;
            } else {
                unset($newAuthors[$index]);
            }
        }

        $lines = $this->addNewAuthors($lines, $newAuthors, $cleaned, $lastAuthor, $indention);

        return \implode("\n", \array_filter($lines, function ($value) {
            return null !== $value;
        }));
    }
1123238
public static function generate(array $authors)
    {
        $newAuthors = [];

        foreach ($authors as $author) {
            $newAuthors[] = (object)$author;
        }

        return $newAuthors;
    }
554537
protected function setAuthors($json, $authors)
    {
        $json['authors'] = [];
        foreach ($authors as $author) {
            list($name, $email) = \explode(' <', $author);

            $config = [
                'name'     => \trim($name),
                'email'    => \trim(\substr($email, 0, -1))
            ];

            if ($this->config->hasMetadata($author, 'homepage')) {
                $config['homepage'] = $this->config->getMetadata($author, 'homepage');
            }

            $config['role'] = $this->config->getMetadata($author, 'role') ?: 'Developer';

            $json['authors'][] = $config;
        }

        return $json;
    }
802332
protected function setAuthors($json, $authors)
    {
        // If no author set yet, use the first one as author.
        if (!isset($json['author'])) {
            $json['author'] = \array_shift($authors);
        }
        $maintainer = $this->convertAuthor($json['author']);

        foreach ($authors as $author) {
            $converted = $this->convertAuthor($author);

            // Ignore the maintainer here.
            if ($converted['email'] === $maintainer['email']) {
                continue;
            }

            $json['contributors'][] = $converted;
        }

        return $json;
    }
342771
public static function getDocBlockFactory(): DocBlockFactory
    {
        if (is_null(self::$docBlockFactory)) {
            self::$docBlockFactory = DocBlockFactory::createInstance();
        }

        return self::$docBlockFactory;
    }
351556
public function outputDocBlock($docblock, $replaceTab = true)
    {
        $code = '';
        $docblock = '/'.$docblock.'/';

        foreach (explode("\n", $docblock) as $line) {
            if ($replaceTab) {
                $code .= str_repeat("\t", $this->level).preg_replace('/^[ \t]+/', ' ', $line).PHP_EOL;
            } else {
                $code .= $line.PHP_EOL;
            }
        }

        $this->lastLine = $code;
        $this->code .= $code;
        ++$this->currentPrints;
    }
1326846
protected function getDocBlockParams(array $tokens, int $docBlockStartIndex, int $docBlockEndIndex): array
    {
        $docBlockParams = [];
        for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) {
            if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
                continue;
            }
            if (!in_array($tokens[$i]['content'], ['@param', '@return'])) {
                continue;
            }

            $classNameIndex = $i + 2;

            if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
                continue;
            }

            $content = $tokens[$classNameIndex]['content'];

            $appendix = '';
            $spacePos = strpos($content, ' ');
            if ($spacePos) {
                $appendix = substr($content, $spacePos);
                $content = substr($content, 0, $spacePos);
            }

            preg_match('/\$[^\s]+/', $appendix, $matches);
            $variable = $matches ? $matches[0] : '';

            $docBlockParams[] = [
                'index' => $classNameIndex,
                'type' => $content,
                'variable' => $variable,
                'appendix' => $appendix,
            ];
        }

        return $docBlockParams;
    }
107048
public function parseFactoryAnnotations($docBlock)
    {
        return $this->parseAnnotations(
            $docBlock,
            '/@factory\("(?P<className>[\/\\\\A-Za-z0-9_-]+?)"(, params={(?P<params>[, \"\n\t*A-Za-z0-9_-]*)})?\)?[ \t]*\r?$/m',
            function (array $matches) {
                if (1 != count($matches[0])) {
                    throw new \InvalidArgumentException();
                }
                current($matches);

                // clean params
                $params = null;
                if (!empty($matches['params'][0])) {
                    $params = $matches['params'][0];
                    foreach (['*', ' ', "\n", "\t", "\r", '"'] as $char) {
                        $params = str_replace($char, '', $params);
                    }
                }

                return [
                    'className' => $matches['className'][0],
                    'params'    => !empty($params)? explode(',', $params):[],
                ];
            }
        );
    }
1231398
protected function insertDocBlock(File $phpCsFile, int $docBlockStartPosition): void
    {
        $phpCsFile->fixer->addContent($docBlockStartPosition, '/**');
        $phpCsFile->fixer->addNewline($docBlockStartPosition);
        $phpCsFile->fixer->addContent($docBlockStartPosition, ' * ' . static::EXPLANATION_CONSTANTS_INTERFACE);
        $phpCsFile->fixer->addNewline($docBlockStartPosition);
        $phpCsFile->fixer->addContent($docBlockStartPosition, ' */');
    }
281762
private function seedBlock($blockTypes, $languages, $users, $contents)
    {
        $blocks = [];
        for ($x = 0; $x < self::RANDOM_BLOCKS; $x++) {
            $block    = $this->seedRandomBlock(
                $blockTypes->random(),
                $languages,
                $users,
                $contents
            );
            $blocks[] = $block;
        }

        return $blocks;
    }
241608
public function addAnnotationsForSource(DocBlock $docBlock) {
    extract(Annotation::getClosureHelpers());
    
    $docBlock->addAnnotation($this->getRelation());
    
    if ($this->type === self::MANY_TO_MANY && $this->sourceSide !== self::INVERSE) { // bei unidirectional brauchen wir natürlich auch einen JoinTable
      $docBlock->addAnnotation($this->getJoinTable());
    }
    
    if ($this->type === self::MANY_TO_ONE || $this->type === self::ONE_TO_ONE) {
      $docBlock->addAnnotation($this->getJoinColumn());
    }
    
    if (($this->type === self::MANY_TO_MANY || $this->type === self::ONE_TO_MANY) && isset($this->orderBy)) {
      $docBlock->addAnnotation($this->orderBy);
    }
    
    foreach ($this->otherAnnotations as $annotation) {
      $docBlock->addAnnotation($annotation);
    }
  }
782139
public function setMetadata($author, $name, $value)
    {
        $this->metadata[$this->arrayKey($author)][$name] = $value;

        return $this;
    }
482692
private function parseDocBlock( $lines )
	{
#		remark( "Parsing DocBlock" );
		$data		= array();
		$descLines	= array();
		foreach( $lines as $line )
		{
			if( preg_match( $this->regexDocParam, $line, $matches ) )
			{
				$param	= array(
					'type'			=> $matches[2],
					'name'			=> $matches[4],
					'description'	=> isset( $matches[5] ) ? $matches[5] : NULL,
				);
				if( !isset( $data['param'] ) )
					$data['param']	= array();
				$data['param'][$matches[4]]	= $param;
			}
			else if( preg_match( "@\*\s+\@return\s+(\w+)\s*(.+)?$@i", $line, $matches ) )
			{
				$data['return']	= array(
					'type'			=> trim( $matches[1] ),
					'description'	=> isset( $matches[2] ) ? trim( $matches[2] ) : "",
				);
			}
			else if( preg_match( "@\*\s+\@author\s+(.+)\s*(<(.+)>)?$@iU", $line, $matches ) )
			{
				$data['author'][]	= array(
					'name'	=> trim( $matches[1] ),
					'mail'	=> isset( $matches[3] ) ? trim( $matches[3] ) : "",
				);
			}
			else if( preg_match( "@\*\s+\@license\s+(\S+)( .+)?$@i", $line, $matches ) )
			{
				if( isset( $matches[2] ) )
				{
					$url	= trim( $matches[1] );
					$name	= trim( $matches[2] );
					if( preg_match( "@^http://@", $matches[2] ) )
					{
						$url	= trim( $matches[2] );
						$name	= trim( $matches[1] );
					}
				}
				else
				{
					$url	= "";
					$name	= trim( $matches[1] );
					if( preg_match( "@^http://@", $matches[1] ) )
						$url	= trim( $matches[1] );
				}
			
				$data['license'][]	= array(
					'url'	=> $url,
					'name'	=> $name,
				);
			}
			else if( preg_match( "/^\*\s+@(\w+)\s+(.+)$/", $line, $matches ) )
			{
				switch( $matches[1] )
				{
					case 'implements':
					case 'deprecated':
					case 'todo':
					case 'see':
					case 'link':
					case 'copyright':
					case 'license':
					case 'author':
					case 'see':
					case 'uses':
					case 'throws':
					case 'link':
						$data[$matches[1]][]	= $matches[2];			
						break;
					default:
						$data[$matches[1]]	= $matches[2];			
						break;
				}
			}
			else if( !$data && preg_match( "/^\*\s*([^@].+)?$/", $line, $matches ) )
				$descLines[]	= isset( $matches[1] ) ? trim( $matches[1] ) : "";
		}
		$data['description']	= trim( implode( "\n", $descLines ) );
		if( !isset( $data['throws'] ) )
			$data['throws']	= array();
		foreach( $data['throws'] as $throws )
		{
			$list	= array();
			$parts	= explode( ",", $throws );
			foreach( $parts as $part )
				$list[]	= trim( $part );
			$data['throws']	= $list;
		}
		return $data;
	}
899382
public function setAuthor(Author $author)
    {
        $this->attachment['author_name'] = $author;

        if ($author->hasIcon()) {
            $this->attachment['author_icon'] = $author->getIcon();
        }

        if ($author->hasLink()) {
            $this->attachment['author_link'] = $author->getLink();
        }

        return $this;
    }
226544
public function addAuthors($authors)
    {
        $app = App::getInstance();

        foreach ($authors as $author) {
            $authorRecord = new ArticleAuthor();
            $authorRecord->setArticle($this)->setAuthor($author)->save();
        }
        return $authors;
    }
50548
public function publish($blocks)
    {
        if ($blocks instanceof PersistentCollection) {
            $blocks = $blocks->getValues();
        }

        if (!$blocks ||
            (is_array($blocks) && !count($blocks))) {
            return;
        }

        if (! is_array($blocks)) {
            $blocks = [$blocks];
        }

        $this->disableRevisionListener();

        $deletes = [];

        foreach ($blocks as $block) {
            if (null !== $revision = $this->revisionManager->getDraftRevision($block)) {
                try {
                    $this->revisionManager->revert($block, $revision);
                } catch (DeletedException $e) {
                    // $this->em->remove($block);
                    $deletes[] = $block;
                }
            }
        }

        $this->em->flush();

        // Cycle through all deleted blocks to perform cascades manually 
        foreach ($deletes as $block) {
            if ($block instanceof CompositeBlock) {
                $descendants = $this->findDescendants($block, false);
            } else {
                $descendants = [$block];
            }

            foreach ($descendants as $descendant) {
                $descendant->setDeletedAt(new \DateTime);
                $this->em->flush($descendant);
            }
        }

        $cacheDriver = $this->em->getConfiguration()->getResultCacheImpl();
        $cacheDriver->deleteAll();

        $this->enableRevisionListener();
    }
284153
def set_author(self, author, email=''):
        """"""
        self.author = author
        self.email = email