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;
        }));
    }
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;
        }));
    }
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 ; } ) ) ; }
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.
Set the author information in doc block .