Skip to content

Conversation

@zigzagdev
Copy link

@zigzagdev zigzagdev commented Oct 30, 2025

Context

The ScoutEngine::delete() method requires an Illuminate\Database\Eloquent\Collection (alias EloquentCollection). However, the thrown TypeError message incorrectly states the expected type as Illuminate\Support\Collection, which misleads during debugging.

Problem

Current message (incorrect):
Argument #1 ($models) must be of type Illuminate\Support\Collection

This contradicts the actual method contract and the behaviour of update(), which already reports EloquentCollection correctly.

Change

Update the thrown TypeError message in ScoutEngine::delete() to name Illuminate\Database\Eloquent\Collection (EloquentCollection) as the expected type.

Tests

Adjust/confirm the expectation in testDeleteRejectsNonEloquentCollection() to assert the corrected message:
Argument #1 ($models) must be of type Illuminate\Database\Eloquent\Collection.
スクリーンショット 2025-10-30 17 00 07

Checklist

  • Add tests and ensure they pass

Copilot AI review requested due to automatic review settings October 30, 2025 08:00
@zigzagdev zigzagdev requested a review from a team as a code owner October 30, 2025 08:00
@zigzagdev zigzagdev requested a review from GromNaN October 30, 2025 08:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the ScoutEngine::delete() method's type assertion error message. The error message was incorrectly referencing Collection::class instead of EloquentCollection::class, making the error message misleading when the wrong collection type was passed.

  • Corrected the error message in ScoutEngine::delete() to accurately reflect the expected type (EloquentCollection instead of Collection)
  • Added a test case to verify the error message when an invalid collection type is provided

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Scout/ScoutEngine.php Fixed error message to use EloquentCollection::class instead of Collection::class
tests/Scout/ScoutEngineTest.php Added test to verify the corrected error message when non-Eloquent collection is passed

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

1 participant