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] Document returned array shape for sync methods #52070

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

devfrey
Copy link
Contributor

@devfrey devfrey commented Jul 9, 2024

I've documented the returned array shape for sync(), syncWithoutDetaching(), and syncWithPivotValues(). This helps with autocompletion and static analysis.

Here's an example from PhpStorm:

screenshot

@@ -67,7 +67,7 @@ public function toggle($ids, $touch = true)
* Sync the intermediate tables with a list of IDs without detaching.
*
* @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
* @return array
* @return array{attached: array, detached: array, updated: array}
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the array inner types should really be defined (e.g., array<string, mixed> for instance)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but I don't think we can be more specific than array<array-key, mixed>, which is the same as array.

@taylorotwell taylorotwell merged commit 1a23e8c into laravel:11.x Jul 10, 2024
30 checks passed
@devfrey devfrey deleted the array-shape-sync-returns branch July 10, 2024 20:58
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.

None yet

3 participants