Skip to content

[11.x] feat: add better closure typing in QueriesRelationships - #54452

Merged
taylorotwell merged 1 commit into
laravel:11.xfrom
calebdw:has_morph_closures
Feb 5, 2025
Merged

[11.x] feat: add better closure typing in QueriesRelationships#54452
taylorotwell merged 1 commit into
laravel:11.xfrom
calebdw:has_morph_closures

Conversation

@calebdw

@calebdw calebdw commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

Hello!

This adds better closure types to the methods in QueriesRelationships:

$query->whereHas($user->posts(), function ($query) {
    // Knows that it's a Post Builder!
    assertType('Illuminate\Database\Eloquent\Builder<Illuminate\Types\Builder\Post>', $query);
});
$query->whereHasMorph($post->taggable(), 'taggable', function ($query, $type) {
    // Knows the parameter types!
    assertType('Illuminate\Database\Eloquent\Builder<Illuminate\Database\Eloquent\Model>', $query);
    assertType('string', $type);
});

Closes calebdw/larastan#25

Thanks!

@taylorotwell

Copy link
Copy Markdown
Member

This one has conflicts.

@taylorotwell
taylorotwell marked this pull request as draft February 5, 2025 10:37
@calebdw
calebdw force-pushed the has_morph_closures branch from 1db9558 to 31061af Compare February 5, 2025 13:42
@calebdw

calebdw commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

@taylorotwell, I've fixed the conflicts, as well as some static analysis failures that were introduced onto 11.x. The remaining failures are on 11.x

@calebdw
calebdw marked this pull request as ready for review February 5, 2025 13:51
@taylorotwell

Copy link
Copy Markdown
Member

@calebdw this has merge conflicts.

@taylorotwell
taylorotwell marked this pull request as draft February 5, 2025 13:53
@calebdw
calebdw force-pushed the has_morph_closures branch from b4471ff to 6317d81 Compare February 5, 2025 13:54
@calebdw

calebdw commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

Should be fixed now

@calebdw
calebdw marked this pull request as ready for review February 5, 2025 13:55
@calebdw
calebdw force-pushed the has_morph_closures branch from 6317d81 to 6f5602b Compare February 5, 2025 13:56
@taylorotwell
taylorotwell merged commit 0c53b3c into laravel:11.x Feb 5, 2025
@calebdw

calebdw commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

Thank you sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Match arm comparison between *NEVER* and ....

2 participants