Add static return type to builder methods (#924)

* Add static return type to builder methods

* formatting

* add eloquent builder test

* change to use assertSame
This commit is contained in:
Daniel Mason
2020-04-22 21:18:54 +02:00
committed by GitHub
parent 5f677edc14
commit 378adeb1f5
2 changed files with 46 additions and 14 deletions
+6 -2
View File
@@ -16,6 +16,8 @@ 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 Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Str;
class Method
{
@@ -266,7 +268,9 @@ class Method
$this->return = $returnValue;
if ($tag->getType() === '$this') {
$tag->setType($this->root);
Str::contains($this->root, Builder::class)
? $tag->setType($this->root . '|static')
: $tag->setType($this->root);
}
} else {
$this->return = null;
@@ -357,7 +361,7 @@ class Method
if ($method) {
$namespace = $method->getDeclaringClass()->getNamespaceName();
$phpdoc = new DocBlock($method, new Context($namespace));
if (strpos($phpdoc->getText(), '{@inheritdoc}') !== false) {
//Not at the end yet, try another parent/interface..
return $this->getInheritDoc($method);