Reuse library "phpdocumentor/reflection-docblock" instead of "barryvdh/reflection-docblock"

This commit is contained in:
Thach Nguyen
2018-01-29 16:26:01 +07:00
parent 07e35d808c
commit 647b8ff0d1
3 changed files with 23 additions and 20 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
"illuminate/filesystem": "4.x",
"illuminate/database": "4.x",
"illuminate/view": "4.x",
"barryvdh/reflection-docblock": "^2.0.4",
"phpdocumentor/reflection-docblock": "^2.0.4",
"symfony/class-loader": "~2.3",
"kdyby/parse-use-statements": "~0.2"
},
+5 -6
View File
@@ -15,10 +15,9 @@ use Illuminate\Support\Str;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\ClassLoader\ClassMapGenerator;
use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\Tag;
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Context;
use phpDocumentor\Reflection\DocBlock\Tag;
/**
* A command to generate autocomplete information for your IDE
@@ -399,7 +398,7 @@ class ModelsCommand extends Command
$properties = array();
$methods = array();
foreach ($phpdoc->getTags() as $tag) {
/* @var Tag|\Barryvdh\Reflection\DocBlock\Tag\PropertyTag|\Barryvdh\Reflection\DocBlock\Tag\MethodTag $tag */
/* @var Tag|Tag\PropertyTag|Tag\MethodTag $tag */
$name = $tag->getName();
if ($name == 'property' || $name == 'property-read' || $name == 'property-write') {
$properties[] = $tag->getVariableName();
@@ -433,7 +432,7 @@ class ModelsCommand extends Command
$phpdoc->appendTag($tag);
}
$serializer = new DocBlockSerializer();
$serializer = new DocBlock\Serializer();
$serializer->getDocComment($phpdoc);
$docComment = $serializer->getDocComment($phpdoc);
+17 -13
View File
@@ -10,17 +10,15 @@
namespace Barryvdh\LaravelIdeHelper;
use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\Tag;
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
use Barryvdh\Reflection\DocBlock\Tag\ParamTag;
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
use phpDocumentor\Reflection\DocBlock;
use phpDocumentor\Reflection\DocBlock\Context;
use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
use Kdyby\ParseUseStatements\UseStatements;
class Method
{
/** @var \Barryvdh\Reflection\DocBlock */
/** @var \phpDocumentor\Reflection\DocBlock */
protected $phpdoc;
/** @var \ReflectionMethod */
@@ -98,7 +96,7 @@ class Method
*/
public function getDocComment($prefix = "\t\t", $trim = false)
{
$serializer = new DocBlockSerializer(1, $prefix);
$serializer = new DocBlock\Serializer(1, $prefix);
$str = $serializer->getDocComment($this->phpdoc);
if ($trim) {
$str = preg_replace(array('/\s+$/m', '#^(\s*/\*\*[\r\n])(?:\s*\*[\r\n])+#u', '#(?:[\r\n]\s*\*)+([\r\n]\s*\*/)$#u'), array('', '$1', '$1'), $str);
@@ -192,20 +190,25 @@ class Method
*/
protected function normalizeReturnTags(DocBlock $phpdoc)
{
$this->return = null;
static $typeProp;
if (!isset($typeProp)) {
$typeProp = new \ReflectionProperty('phpDocumentor\Reflection\DocBlock\Tag\ReturnTag', 'type');
$typeProp->setAccessible(true);
}
$this->return = null;
//Get the return type and adjust them for better autocomplete
foreach ($phpdoc->getTags() as $tag) {
if ($tag instanceof ReturnTag) {
// Convert the keywords
$typeValue = static::convertKeywords($tag->getType(false));
$tag->setType($typeValue);
$typeValue = static::convertKeywords($typeProp->getValue($tag));
$typeProp->setValue($tag, $typeValue);
// Get the expanded type
$typeValue = $tag->getType();
// Replace the interfaces
if (get_class($tag) === ReturnTag::class) {
if (preg_match('/\bReturnTag$/', get_class($tag))) {
foreach ($this->interfaces as $interface => $real) {
$typeValue = preg_replace('/(^|\|)' . preg_quote($interface, '/') . '\b/', $real, $typeValue);
}
@@ -213,7 +216,8 @@ class Method
}
// Re-set the type
$tag->setType($typeValue);
$typeProp->setValue($tag, $typeValue);
$tag->setDescription($tag->getDescription());
}
}
}