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

RedirectResponse::with() expects array|string, true given #586

Closed
matthewsuan opened this issue May 29, 2020 · 3 comments · Fixed by #1016
Closed

RedirectResponse::with() expects array|string, true given #586

matthewsuan opened this issue May 29, 2020 · 3 comments · Fixed by #1016
Labels
bug Something isn't working

Comments

@matthewsuan
Copy link

matthewsuan commented May 29, 2020

  • Larastan Version: 0.5.8
  • --level used: 5

Description

The following code throws an error:

return redirect()->back()->withSuccess(true);
Parameter #1 $key of method Illuminate\Http\RedirectResponse::with() expects array|string, true given.
@szepeviktor szepeviktor changed the title RedirectResponse throws an error RedirectResponse::with() expects array|string, true given May 29, 2020
@canvural
Copy link
Collaborator

Hi,

Is withSucess a macro you wrote? I don't think this is in Laravel.

And the error message is different than the code example you shared. So I'm not sure what the real issue is. But the error message is correct, you can't pass true to with method.

@Daanra
Copy link
Contributor

Daanra commented May 29, 2020

RedirectResponse can dynamically forward calls to with just like a Builder does with where:

public function __call($method, $parameters)
{
        // ...
        if (Str::startsWith($method, 'with')) {
            return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
        }

        static::throwBadMethodCallException($method);
}

So withSuccess(true) seems like it would be equivalent to with('succes', true)

Also see: https://github.com/nunomaduro/larastan/blob/0a4edcd23955c0cd209395d44ed476339d003605/src/Methods/Pipes/RedirectResponseWiths.php#L28-L37

@canvural
Copy link
Collaborator

RedirectResponse can dynamically forward calls to with just like a Builder does with where:

Ah, didn't know that!

Also see:

https://github.com/nunomaduro/larastan/blob/0a4edcd23955c0cd209395d44ed476339d003605/src/Methods/Pipes/RedirectResponseWiths.php#L28-L37

Ok, so it seems this is indeed a bug here.

@canvural canvural added the bug Something isn't working label May 29, 2020
@nunomaduro nunomaduro changed the title RedirectResponse::with() expects array|string, true given RedirectResponse::with() expects array|string, true given Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants