private function parseMemberDocblock($member, Doc $doc = null) { if ($doc !== null) { $member->setDocblock($doc->getReformattedText()); $docblock = $member->getDocblock(); $member->setDescription($docblock->getShortDescription()); $member->setLongDescription($docblock->getLongDescription()); $vars = $docblock->getTags('var'); if ($vars->size() > 0) { $var = $vars->get(0); $member->setType($var->getType(), $var->getDescription()); } } }
/** * Adds the type/symbol to PHPDOC if not already present. * @param Doc $phpDoc * @param string $type E.g. 'Html' or 'HtmlHelper' * @param string $symbol E.g. 'Html' * @param string $indent The indentation so when adding properties it matches * general PHPDOC indentation * @return boolean True if property was added, false if not */ private static function addPropertyIfNotExists(Doc $phpDoc, $type, $symbol, $indent) { $text = $phpDoc->getText(); # split into lines but ensure we keep the existing line ending format $lines = self::splitStringIntoLines($text); # try to find the symbol we're going to add $reSymMatch = '/\\*\\s*@property\\s+' . preg_quote($type, '/') . '\\s+\\$' . preg_quote($symbol, '/') . '/i'; foreach ($lines as $line) { if (preg_match($reSymMatch, $line)) { return false; } } # We haven't found it, so add it at the end before the comment ends $addedLine = $indent . '* @property ' . $type . ' $' . $symbol; array_splice($lines, count($lines) - 1, 0, [$addedLine . self::extractEol($text)]); $phpDoc->setText(join('', $lines)); return true; }