Use DocBlock Serializer

Instead of doing it here.
This commit is contained in:
Barry vd. Heuvel
2013-05-26 23:10:09 +02:00
parent 427295f993
commit fde71b0ee8
2 changed files with 18 additions and 35 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
"illuminate/support": "4.0.x", "illuminate/support": "4.0.x",
"illuminate/console": "4.0.x", "illuminate/console": "4.0.x",
"illuminate/filesystem": "4.0.x", "illuminate/filesystem": "4.0.x",
"phpdocumentor/reflection-docblock": "2.0.*", "phpdocumentor/reflection-docblock": "dev-master",
"symfony/class-loader": "2.3.*" "symfony/class-loader": "2.3.*"
}, },
"autoload": { "autoload": {
@@ -4,6 +4,9 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use DocBlock\Parser; use DocBlock\Parser;
use Illuminate\Foundation\AliasLoader; use Illuminate\Foundation\AliasLoader;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Serializer as DocBlockSerializer;
/** /**
* A command to generate autocomplete information for your IDE * A command to generate autocomplete information for your IDE
* *
@@ -247,22 +250,18 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
return $output; return $output;
} }
$phpdoc = new \phpDocumentor\Reflection\DocBlock($method); $phpdoc = new DocBlock($method);
$serializer = new DocBlockSerializer("\t", 1);
$description = $phpdoc->getText();
$description = $phpdoc->getShortDescription();
$longDescription = $phpdoc->getLongDescription()->getContents();
if($longDescription){
$description .= "\n".$longDescription;
}
if(strpos($description, '{@inheritdoc}') !== false){ if(strpos($description, '{@inheritdoc}') !== false){
$inheritdoc = $this->getInheritDoc($method); $inheritdoc = $this->getInheritDoc($method);
$inheritDescription = $inheritdoc->getShortDescription(); $inheritDescription = $inheritdoc->getText();
$inheritLongDescription = $inheritdoc->getLongDescription()->getContents();
if($inheritLongDescription){
$inheritDescription .= "\n".$inheritLongDescription;
}
$description = str_replace('{@inheritdoc}', $inheritDescription, $description); $description = str_replace('{@inheritdoc}', $inheritDescription, $description);
$phpdoc->setText($description);
$inheritTags = $inheritdoc->getTags(); $inheritTags = $inheritdoc->getTags();
if($inheritTags){ if($inheritTags){
foreach($inheritTags as $tag){ foreach($inheritTags as $tag){
@@ -271,20 +270,13 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
} }
} }
} }
$description = str_replace("\n", "\n\t * ", $description);
$output .= "\t/**\n\t * ".$description."\n";
$output .= "\t *\n\t * @static\n";
$paramTags = $phpdoc->getTagsByName('param'); $phpdoc->appendTag(Tag::createInstance('@static', $phpdoc));
if(!empty($paramTags)){
foreach ($paramTags as $tag)
{
$output .="\t * @param\t".$tag->getType()."\t".$tag->getVariableName()."\t".$tag->getDescription()."\n";
}
}
$returnTags = $phpdoc->getTagsByName('return'); $returnTags = $phpdoc->getTagsByName('return');
if($returnTags){ if($returnTags){
/** @var $tag */
$tag = reset($returnTags); $tag = reset($returnTags);
$returnValue = $tag->getType(); $returnValue = $tag->getType();
@@ -296,21 +288,12 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
}elseif(!$sublime and $alias == 'Eloquent' and in_array($method->name, array('all', 'get'))){ }elseif(!$sublime and $alias == 'Eloquent' and in_array($method->name, array('all', 'get'))){
$returnValue .= "|Eloquent[]|static[]"; $returnValue .= "|Eloquent[]|static[]";
} }
$output .= "\t * @return\t".$returnValue."\t".$tag->getDescription()."\n"; $tag->setContent($returnValue . " ". $tag->getDescription());
}else{ }else{
$returnValue = null; $returnValue = null;
} }
$allTags = $phpdoc->getTags(); $output .= $serializer->getDocComment($phpdoc) ."\n\t public ".($static ? 'static' : '')." function ".$method->name."(";
if($allTags){
foreach($allTags as $tag){
if(!in_array($tag->getName(), array('return', 'param'))){
$output .= "\t * @".$tag->getName() ." ". $tag->getContent()."\n";
}
}
}
$output .= "\t */\n\t public ".($static ? 'static' : '')." function ".$method->name."(";
$params = array(); $params = array();
$paramsWithDefault = array(); $paramsWithDefault = array();
@@ -364,8 +347,8 @@ namespace {\n\tdie('Only to be used as an helper for your IDE');\n}\n\n";
$method = $reflectionMethod->getPrototype(); $method = $reflectionMethod->getPrototype();
} }
if($method){ if($method){
$phpdoc = new \phpDocumentor\Reflection\DocBlock($method); $phpdoc = new DocBlock($method);
if(strpos($phpdoc->getShortDescription(), '{@inheritdoc}') !== false || strpos($phpdoc->getLongDescription(), '{@inheritdoc}') !== false ){ if(strpos($phpdoc->getText(), '{@inheritdoc}') !== false ){
//Not at the end yet, try another parent/interface.. //Not at the end yet, try another parent/interface..
return $this->getInheritDoc($method); return $this->getInheritDoc($method);
}else{ }else{