diff --git a/src/Alias.php b/src/Alias.php index 80d1c2b3d..7f2eae20c 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -413,7 +413,9 @@ protected function detectMethods() protected function getReturnTypeNormalizers($class) { if ($this->alias === 'Eloquent' && in_array($class->getName(), [EloquentBuilder::class, QueryBuilder::class])) { - return ['$this' => '\\' . EloquentBuilder::class . '|static']; + return [ + '$this' => '\\' . EloquentBuilder::class . ($this->config->get('ide-helper.use_generics_annotations') ? '' : '|static') + ]; } return []; diff --git a/tests/MethodTest.php b/tests/MethodTest.php index 5d60e47f5..f5beafbba 100644 --- a/tests/MethodTest.php +++ b/tests/MethodTest.php @@ -94,7 +94,7 @@ public function testEloquentBuilderNormalizedReturnType() $reflectionClass = new \ReflectionClass(EloquentBuilder::class); $reflectionMethod = $reflectionClass->getMethod('where'); - $method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '|static']); + $method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '']); $output = <<<'DOC' /** @@ -104,7 +104,7 @@ public function testEloquentBuilderNormalizedReturnType() * @param mixed $operator * @param mixed $value * @param string $boolean - * @return \Illuminate\Database\Eloquent\Builder|static + * @return \Illuminate\Database\Eloquent\Builder * @static */ DOC; @@ -114,7 +114,7 @@ public function testEloquentBuilderNormalizedReturnType() $this->assertSame(['$column', '$operator', '$value', '$boolean'], $method->getParams(false)); $this->assertSame(['$column', "\$operator = null", "\$value = null", "\$boolean = 'and'"], $method->getParamsWithDefault(false)); $this->assertTrue($method->shouldReturn()); - $this->assertSame('\Illuminate\Database\Eloquent\Builder|static', rtrim($method->getReturnTag()->getType())); + $this->assertSame('\Illuminate\Database\Eloquent\Builder', rtrim($method->getReturnTag()->getType())); } /** @@ -125,7 +125,7 @@ public function testQueryBuilderNormalizedReturnType() $reflectionClass = new \ReflectionClass(QueryBuilder::class); $reflectionMethod = $reflectionClass->getMethod('whereNull'); - $method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '|static']); + $method = new Method($reflectionMethod, 'Builder', $reflectionClass, null, [], [], ['$this' => '\\' . EloquentBuilder::class . '']); $output = <<<'DOC' /** @@ -134,7 +134,7 @@ public function testQueryBuilderNormalizedReturnType() * @param string|array|\Illuminate\Contracts\Database\Query\Expression $columns * @param string $boolean * @param bool $not - * @return \Illuminate\Database\Eloquent\Builder|static + * @return \Illuminate\Database\Eloquent\Builder * @static */ DOC; @@ -145,7 +145,7 @@ public function testQueryBuilderNormalizedReturnType() $this->assertSame(['$columns', '$boolean', '$not'], $method->getParams(false)); $this->assertSame(['$columns', "\$boolean = 'and'", '$not = false'], $method->getParamsWithDefault(false)); $this->assertTrue($method->shouldReturn()); - $this->assertSame('\Illuminate\Database\Eloquent\Builder|static', rtrim($method->getReturnTag()->getType())); + $this->assertSame('\Illuminate\Database\Eloquent\Builder', rtrim($method->getReturnTag()->getType())); } /**