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

[12.x] DocBlock: Changed typehint for Arr::partition method #54896

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

AndrewMast
Copy link
Contributor

DocBlock Change

Changed the docblock for the newly introduced Arr::partition (#54859). The typehint for the $callback parameter now communicates what the callable will be receiving and should be returning (callable(TValue, TKey): bool)

Example

/**
 * @var array<string, bool>
 */
$names = [
    'taylor' => true,
    'francis' => true,
    'primeagen' => false,
];

// Before
[$realNames, $aliasNames] = Arr::partition(
    $names,
    fn (/** @param mixed */ $value, /** @param mixed */ $key) => /** @return mixed */ $value,
);

// After
[$realNames, $aliasNames] = Arr::partition(
    $names,
    fn (/** @param bool */ $value, /** @param string */ $key) => /** @return bool */ $value,
);

Why

Arr::partition was recently added and does not have a generic typehint for the $callback parameter. I matched the typehint to be similar to the typehints for the preexisting Arr::first and Arr::last callbacks.

@taylorotwell taylorotwell merged commit 18a3622 into laravel:12.x Mar 4, 2025
40 of 41 checks passed
@AndrewMast AndrewMast deleted the docblock-array-partition branch March 5, 2025 05:41
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.

2 participants