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

Merged
merged 1 commit into from
Feb 5, 2025

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!

@taylorotwell
Copy link
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
Copy link
Contributor Author

calebdw commented Feb 5, 2025

@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
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
Copy link
Contributor Author

calebdw commented Feb 5, 2025

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
38 checks passed
@calebdw
Copy link
Contributor Author

calebdw commented Feb 5, 2025

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