diff --git a/tests/acceptance/EloquentBuilderTypes.feature b/tests/acceptance/EloquentBuilderTypes.feature index 05b69b9..12daf5a 100644 --- a/tests/acceptance/EloquentBuilderTypes.feature +++ b/tests/acceptance/EloquentBuilderTypes.feature @@ -15,73 +15,78 @@ Feature: Eloquent Builder types """ + And I have the following code preamble + """ + + * @return Builder */ - public function getNewQuery(): \Illuminate\Database\Eloquent\Builder + public function getNewQuery(): Builder { return User::query(); } /** - * @return \Illuminate\Database\Eloquent\Builder + * @return Builder */ - public function getNewModelQuery(): \Illuminate\Database\Eloquent\Builder + public function getNewModelQuery(): Builder { return (new User())->newModelQuery(); } /** - * @param \Illuminate\Database\Eloquent\Builder $builder + * @param Builder $builder */ - public function firstOrFailFromBuilderInstance(\Illuminate\Database\Eloquent\Builder $builder): User { + public function firstOrFailFromBuilderInstance(Builder $builder): User { return $builder->firstOrFail(); } /** - * @param \Illuminate\Database\Eloquent\Builder $builder + * @param Builder $builder */ - public function findOrFailFromBuilderInstance(\Illuminate\Database\Eloquent\Builder $builder): User { + public function findOrFailFromBuilderInstance(Builder $builder): User { return $builder->findOrFail(1); } /** - * @param \Illuminate\Database\Eloquent\Builder $builder - * @return \Illuminate\Database\Eloquent\Collection + * @param Builder $builder + * @return Collection */ - public function findMultipleOrFailFromBuilderInstance(\Illuminate\Database\Eloquent\Builder $builder): \Illuminate\Database\Eloquent\Collection { + public function findMultipleOrFailFromBuilderInstance(Builder $builder): Collection { return $builder->findOrFail([1, 2]); } /** - * @param \Illuminate\Database\Eloquent\Builder $builder + * @param Builder $builder */ - public function findOne(\Illuminate\Database\Eloquent\Builder $builder): ?User { + public function findOne(Builder $builder): ?User { return $builder->find(1); } /** - * @param \Illuminate\Database\Eloquent\Builder $builder + * @param Builder $builder */ - public function findViaArray(\Illuminate\Database\Eloquent\Builder $builder): \Illuminate\Database\Eloquent\Collection { + public function findViaArray(Builder $builder): Collection { return $builder->find([1]); } /** - * @return \Illuminate\Database\Eloquent\Builder + * @return Builder */ - public function getWhereBuilderViaInstance(array $attributes): \Illuminate\Database\Eloquent\Builder { + public function getWhereBuilderViaInstance(array $attributes): Builder { return (new User())->where($attributes); } } @@ -90,10 +95,16 @@ Feature: Eloquent Builder types Then I see no errors Scenario: can call static methods on model - Given I have the following code + Given I have the following code preamble """ + * @return Builder */ - public function getWhereBuilderViaStatic(array $attributes): \Illuminate\Database\Eloquent\Builder + public function getWhereBuilderViaStatic(array $attributes): Builder { return User::where($attributes); } /** - * @psalm-return \Illuminate\Database\Eloquent\Collection + * @psalm-return Collection */ - public function getWhereViaStatic(array $attributes): \Illuminate\Database\Eloquent\Collection + public function getWhereViaStatic(array $attributes): Collection { return User::where($attributes)->get(); } @@ -122,20 +133,25 @@ Feature: Eloquent Builder types Then I see no errors Scenario: - Given I have the following code + Given I have the following code preamble """ + * @return Builder */ - public function test_failure(): \Illuminate\Database\Eloquent\Builder + public function test_failure(): Builder { return User::fakeQueryMethodThatDoesntExist(); } @@ -150,11 +166,6 @@ Feature: Eloquent Builder types Scenario: can call methods on underlying query builder Given I have the following code """ - $builder * @psalm-return Builder @@ -170,11 +181,6 @@ Feature: Eloquent Builder types Given I have the "laravel/framework" package satisfying the "6.*" And I have the following code """ - $builder * @psalm-return User @@ -201,11 +207,6 @@ Feature: Eloquent Builder types Given I have the "laravel/framework" package satisfying the ">= 8.0" And I have the following code """ - $builder * @psalm-return User