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

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

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from

Conversation

calebdw
Copy link
Contributor

@calebdw calebdw commented Feb 3, 2025

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!

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 ....
1 participant