Skip to content

Replaced map with reduce to pass changed values.#55

Open
elnur-ibr wants to merge 1 commit into
worksome:mainfrom
elnur-ibr:replaced-map-with-reduce
Open

Replaced map with reduce to pass changed values.#55
elnur-ibr wants to merge 1 commit into
worksome:mainfrom
elnur-ibr:replaced-map-with-reduce

Conversation

@elnur-ibr
Copy link
Copy Markdown

While using two or more dependent callback on define it was not passing already resolved data.

class UserStoreRequestFactory extends RequestFactory
{
    public function definition(): array
    {
        return [
            'name'       => $this->faker()->name,
            'status'     => 'active',
            'email'      => $this->faker()->email,
            'level'      => 1,
            'client_ids' => fn (array $data) => [1,2,3],
            'brand_ids'  => fn (array $data) => $this->getBrandIds(data['client_ids']),
        ];
    }
}

public function getBrandIds(array $clientIds)

It was throwing error Argument #1 ($clientIds) must be of type array, Closure given, called in

@etibarrustam
Copy link
Copy Markdown

I am facing the same issue. Can it be fixed, please?

@SuperDJ
Copy link
Copy Markdown
Contributor

SuperDJ commented Jun 27, 2025

Can you add a test that would fail without the change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants