phpDocumentor\Reflection\DocBlock::splitDocBlock PHP Method

splitDocBlock() protected method

Splits the DocBlock into a short description, long description and block of tags.
Author: RichardJ Special thanks to RichardJ for the regex responsible for the split.
protected splitDocBlock ( string $comment ) : string[]
$comment string Comment to split into the sub-parts.
return string[] containing the short-, long description and an element containing the tags.
    protected function splitDocBlock($comment)
    {
        if (strpos($comment, '@') === 0) {
            $matches = array('', '', $comment);
        } else {
            // clears all extra horizontal whitespace from the line endings
            // to prevent parsing issues
            $comment = preg_replace('/\\h*$/Sum', '', $comment);
            /*
             * Splits the docblock into a short description, long description and
             * tags section
             * - The short description is started from the first character until
             *   a dot is encountered followed by a whitespace OR
             *   two consecutive newlines (horizontal whitespace is taken into
             *   account to consider spacing errors)
             * - The long description, any character until a new line is
             *   encountered followed by an @ and word characters (a tag).
             *   This is optional.
             * - Tags; the remaining characters
             *
             * Big thanks to RichardJ for contributing this Regular Expression
             */
            preg_match('/
        \\A (
          [^\\n.]+
          (?:
            (?! \\. \\s | \\n{2} ) # disallow the first seperator here
            [\\n.] (?! [ \\t]* @\\pL ) # disallow second seperator
            [^\\n.]+
          )*
          \\.?
        )
        (?:
          \\s* # first seperator (actually newlines but it\'s all whitespace)
          (?! @\\pL ) # disallow the rest, to make sure this one doesn\'t match,
          #if it doesn\'t exist
          (
            [^\\n]+
            (?: \\n+
              (?! [ \\t]* @\\pL ) # disallow second seperator (@param)
              [^\\n]+
            )*
          )
        )?
        (\\s+ [\\s\\S]*)? # everything that follows
        /ux', $comment, $matches);
            array_shift($matches);
        }
        while (count($matches) < 3) {
            $matches[] = '';
        }
        return $matches;
    }