mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +00:00
Reuse library "phpdocumentor/reflection-docblock" instead of "barryvdh/reflection-docblock"
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"illuminate/filesystem": "4.x",
|
"illuminate/filesystem": "4.x",
|
||||||
"illuminate/database": "4.x",
|
"illuminate/database": "4.x",
|
||||||
"illuminate/view": "4.x",
|
"illuminate/view": "4.x",
|
||||||
"barryvdh/reflection-docblock": "^2.0.4",
|
"phpdocumentor/reflection-docblock": "^2.0.4",
|
||||||
"symfony/class-loader": "~2.3",
|
"symfony/class-loader": "~2.3",
|
||||||
"kdyby/parse-use-statements": "~0.2"
|
"kdyby/parse-use-statements": "~0.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ use Illuminate\Support\Str;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
use Symfony\Component\ClassLoader\ClassMapGenerator;
|
||||||
use Barryvdh\Reflection\DocBlock;
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use Barryvdh\Reflection\DocBlock\Context;
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
use Barryvdh\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command to generate autocomplete information for your IDE
|
* A command to generate autocomplete information for your IDE
|
||||||
@@ -399,7 +398,7 @@ class ModelsCommand extends Command
|
|||||||
$properties = array();
|
$properties = array();
|
||||||
$methods = array();
|
$methods = array();
|
||||||
foreach ($phpdoc->getTags() as $tag) {
|
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();
|
$name = $tag->getName();
|
||||||
if ($name == 'property' || $name == 'property-read' || $name == 'property-write') {
|
if ($name == 'property' || $name == 'property-read' || $name == 'property-write') {
|
||||||
$properties[] = $tag->getVariableName();
|
$properties[] = $tag->getVariableName();
|
||||||
@@ -433,7 +432,7 @@ class ModelsCommand extends Command
|
|||||||
$phpdoc->appendTag($tag);
|
$phpdoc->appendTag($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
$serializer = new DocBlockSerializer();
|
$serializer = new DocBlock\Serializer();
|
||||||
$serializer->getDocComment($phpdoc);
|
$serializer->getDocComment($phpdoc);
|
||||||
$docComment = $serializer->getDocComment($phpdoc);
|
$docComment = $serializer->getDocComment($phpdoc);
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -10,17 +10,15 @@
|
|||||||
|
|
||||||
namespace Barryvdh\LaravelIdeHelper;
|
namespace Barryvdh\LaravelIdeHelper;
|
||||||
|
|
||||||
use Barryvdh\Reflection\DocBlock;
|
use phpDocumentor\Reflection\DocBlock;
|
||||||
use Barryvdh\Reflection\DocBlock\Context;
|
use phpDocumentor\Reflection\DocBlock\Context;
|
||||||
use Barryvdh\Reflection\DocBlock\Tag;
|
use phpDocumentor\Reflection\DocBlock\Tag;
|
||||||
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
|
use phpDocumentor\Reflection\DocBlock\Tag\ReturnTag;
|
||||||
use Barryvdh\Reflection\DocBlock\Tag\ParamTag;
|
|
||||||
use Barryvdh\Reflection\DocBlock\Serializer as DocBlockSerializer;
|
|
||||||
use Kdyby\ParseUseStatements\UseStatements;
|
use Kdyby\ParseUseStatements\UseStatements;
|
||||||
|
|
||||||
class Method
|
class Method
|
||||||
{
|
{
|
||||||
/** @var \Barryvdh\Reflection\DocBlock */
|
/** @var \phpDocumentor\Reflection\DocBlock */
|
||||||
protected $phpdoc;
|
protected $phpdoc;
|
||||||
|
|
||||||
/** @var \ReflectionMethod */
|
/** @var \ReflectionMethod */
|
||||||
@@ -98,7 +96,7 @@ class Method
|
|||||||
*/
|
*/
|
||||||
public function getDocComment($prefix = "\t\t", $trim = false)
|
public function getDocComment($prefix = "\t\t", $trim = false)
|
||||||
{
|
{
|
||||||
$serializer = new DocBlockSerializer(1, $prefix);
|
$serializer = new DocBlock\Serializer(1, $prefix);
|
||||||
$str = $serializer->getDocComment($this->phpdoc);
|
$str = $serializer->getDocComment($this->phpdoc);
|
||||||
if ($trim) {
|
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);
|
$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)
|
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
|
//Get the return type and adjust them for better autocomplete
|
||||||
foreach ($phpdoc->getTags() as $tag) {
|
foreach ($phpdoc->getTags() as $tag) {
|
||||||
if ($tag instanceof ReturnTag) {
|
if ($tag instanceof ReturnTag) {
|
||||||
// Convert the keywords
|
// Convert the keywords
|
||||||
$typeValue = static::convertKeywords($tag->getType(false));
|
$typeValue = static::convertKeywords($typeProp->getValue($tag));
|
||||||
$tag->setType($typeValue);
|
$typeProp->setValue($tag, $typeValue);
|
||||||
|
|
||||||
// Get the expanded type
|
// Get the expanded type
|
||||||
$typeValue = $tag->getType();
|
$typeValue = $tag->getType();
|
||||||
|
|
||||||
// Replace the interfaces
|
// Replace the interfaces
|
||||||
if (get_class($tag) === ReturnTag::class) {
|
if (preg_match('/\bReturnTag$/', get_class($tag))) {
|
||||||
foreach ($this->interfaces as $interface => $real) {
|
foreach ($this->interfaces as $interface => $real) {
|
||||||
$typeValue = preg_replace('/(^|\|)' . preg_quote($interface, '/') . '\b/', $real, $typeValue);
|
$typeValue = preg_replace('/(^|\|)' . preg_quote($interface, '/') . '\b/', $real, $typeValue);
|
||||||
}
|
}
|
||||||
@@ -213,7 +216,8 @@ class Method
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-set the type
|
// Re-set the type
|
||||||
$tag->setType($typeValue);
|
$typeProp->setValue($tag, $typeValue);
|
||||||
|
$tag->setDescription($tag->getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user