[10.x] Add Generic Docblocks To Builder #857
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the Docblocks necessary for static analysis to make a Scout Builder generic over a model based on the Searchable trait.
I ran into the issue when iterating over the search results in a map and static analysis was expecting a model and not a child class of the model.
This is admittedly my first time setting something like this up, but I looked at how the generics were implemented for the Eloquent Builder and went from there. It's resolved the static analysis issues in the original project and the changes were simple enough that I think it's correct.
It is backed up by some PHPStan type tests that are also newly introduced in this PR. I copied the setup from laravel/framework to adjust the CI process here. However, I would understand if that's not something that is desired out in a PR at this time and so I did all of the test and CI changes as a separate commit that could easily be reverted if desired.