Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added conditional return types #1236

Merged
merged 6 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Improvements
* feat: Added conditional return types

### Fixes

* fix: Change QueryBuilder::newQuery() @return from `$this` to `static`
Expand Down
6 changes: 3 additions & 3 deletions stubs/BelongsToMany.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BelongsToMany extends Relation
*
* @param mixed $id
* @param array<int, (model-property<TRelatedModel>|'*')>|model-property<TRelatedModel>|'*' $columns
* @return \Illuminate\Support\Collection<int, TRelatedModel>|TRelatedModel
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Support\Collection<int, TRelatedModel> : TRelatedModel)
*/
public function findOrNew($id, $columns = ['*']);

Expand Down Expand Up @@ -51,7 +51,7 @@ class BelongsToMany extends Relation
*
* @param mixed $id
* @param array<int, mixed> $columns
* @return TRelatedModel|\Illuminate\Database\Eloquent\Collection<int, TRelatedModel>|null
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TRelatedModel> : TRelatedModel)|null
*/
public function find($id, $columns = ['*']);

Expand All @@ -69,7 +69,7 @@ class BelongsToMany extends Relation
*
* @param mixed $id
* @param array<int, mixed> $columns
* @return TRelatedModel|\Illuminate\Database\Eloquent\Collection<int, TRelatedModel>
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TRelatedModel> : TRelatedModel)
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
Expand Down
4 changes: 2 additions & 2 deletions stubs/EloquentBuilder.stub
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Builder
*
* @param mixed $id
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<int, TModelClass>|null
* @phpstan-return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TModelClass> : TModelClass)|null
*/
public function find($id, $columns = ['*']);

Expand All @@ -82,7 +82,7 @@ class Builder
*
* @param mixed $id
* @param array<int, (model-property<TModelClass>|'*')>|model-property<TModelClass>|'*' $columns
* @phpstan-return TModelClass|\Illuminate\Database\Eloquent\Collection<int, TModelClass>
* @phpstan-return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Database\Eloquent\Collection<int, TModelClass> : TModelClass)
*
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException
*/
Expand Down
2 changes: 1 addition & 1 deletion stubs/HasOneOrMany.stub
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class HasOneOrMany extends Relation
*
* @param mixed $id
* @param array<int, mixed> $columns
* @return \Illuminate\Support\Collection<int, TRelatedModel>|TRelatedModel
* @return ($id is (\Illuminate\Contracts\Support\Arrayable<array-key, mixed>|array<mixed>) ? \Illuminate\Support\Collection<int, TRelatedModel> : TRelatedModel)
*/
public function findOrNew($id, $columns = ['*']);

Expand Down