本文整理汇总了PHP中phpDocumentor\Reflection\DocBlock::setText方法的典型用法代码示例。如果您正苦于以下问题:PHP DocBlock::setText方法的具体用法?PHP DocBlock::setText怎么用?PHP DocBlock::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpDocumentor\Reflection\DocBlock
的用法示例。
在下文中一共展示了DocBlock::setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: docblock
/**
* Generate docblock.
*
* @param string $class
* @param array $properties
* @param array $methods
* @return mixed
*/
public function docblock($class, $properties, $methods)
{
$phpdoc = new DocBlock('');
$phpdoc->setText($class);
foreach ($properties as $property) {
$tag = Tag::createInstance("@{$property['type']} {$property['return']} {$property['name']}", $phpdoc);
$phpdoc->appendTag($tag);
}
foreach ($methods as $method) {
$tag = Tag::createInstance("@method {$method['type']} {$method['return']} {$method['name']}({$method['arguments']})", $phpdoc);
$phpdoc->appendTag($tag);
}
$serializer = new DocBlockSerializer();
$docComment = $serializer->getDocComment($phpdoc);
return $docComment;
}
示例2: createPhpDocs
/**
* @param string $class
* @return string
*/
protected function createPhpDocs($class)
{
$reflection = new \ReflectionClass($class);
$namespace = $reflection->getNamespaceName();
$classname = $reflection->getShortName();
$originalDoc = $reflection->getDocComment();
if ($this->reset) {
$phpdoc = new DocBlock('', new Context($namespace));
} else {
$phpdoc = new DocBlock($reflection, new Context($namespace));
}
if (!$phpdoc->getText()) {
$phpdoc->setText($class);
}
$properties = array();
$methods = array();
foreach ($phpdoc->getTags() as $tag) {
$name = $tag->getName();
if ($name == "property" || $name == "property-read" || $name == "property-write") {
$properties[] = $tag->getVariableName();
} elseif ($name == "method") {
$methods[] = $tag->getMethodName();
}
}
foreach ($this->properties as $name => $property) {
$name = "\${$name}";
if (in_array($name, $properties)) {
continue;
}
if ($property['read'] && $property['write']) {
$attr = 'property';
} elseif ($property['write']) {
$attr = 'property-write';
} else {
$attr = 'property-read';
}
$tag = Tag::createInstance("@{$attr} {$property['type']} {$name} {$property['comment']}", $phpdoc);
$phpdoc->appendTag($tag);
}
foreach ($this->methods as $name => $method) {
if (in_array($name, $methods)) {
continue;
}
$arguments = implode(', ', $method['arguments']);
$tag = Tag::createInstance("@method static {$method['type']} {$name}({$arguments})", $phpdoc);
$phpdoc->appendTag($tag);
}
$serializer = new DocBlockSerializer();
$serializer->getDocComment($phpdoc);
$docComment = $serializer->getDocComment($phpdoc);
if ($this->write) {
$filename = $reflection->getFileName();
$contents = \File::get($filename);
if ($originalDoc) {
$contents = str_replace($originalDoc, $docComment, $contents);
} else {
$needle = "class {$classname}";
$replace = "{$docComment}\nclass {$classname}";
$pos = strpos($contents, $needle);
if ($pos !== false) {
$contents = substr_replace($contents, $replace, $pos, strlen($needle));
}
}
if (\File::put($filename, $contents)) {
$this->info('Written new phpDocBlock to ' . $filename);
}
}
$output = "namespace {$namespace}{\n{$docComment}\n\tclass {$classname} {}\n}\n\n";
return $output;
}
示例3: normalizeDescription
/**
* Get the description and get the inherited docs.
*
*/
protected function normalizeDescription()
{
//Get the short + long description from the DocBlock
$description = $this->phpdoc->getText();
//Loop through parents/interfaces, to fill in {@inheritdoc}
if (strpos($description, '{@inheritdoc}') !== false) {
$inheritdoc = $this->getInheritDoc($this->method);
$inheritDescription = $inheritdoc->getText();
$description = str_replace('{@inheritdoc}', $inheritDescription, $description);
$this->phpdoc->setText($description);
//Add the tags that are inherited
$inheritTags = $inheritdoc->getTags();
if ($inheritTags) {
foreach ($inheritTags as $tag) {
$tag->setDocBlock();
$this->phpdoc->appendTag($tag);
}
}
}
}
示例4: mergeGeneratedTagsIntoDocBlock
/**
* @param string $existingDocBlock
* @return string
*/
protected function mergeGeneratedTagsIntoDocBlock($existingDocBlock)
{
$docBlock = new DocBlock($this->removeExistingSupportedTags($existingDocBlock));
if (!$docBlock->getText()) {
$docBlock->setText('Class ' . $this->className);
}
foreach ($this->getGeneratedTags() as $tag) {
$docBlock->appendTag($tag);
}
$serializer = new DocBlockSerializer();
$docBlock = $serializer->getDocComment($docBlock);
return $docBlock;
}