Skip to content

Conversation

@rbarden
Copy link
Contributor

@rbarden rbarden commented Mar 12, 2021

New PR to master for #36567

This PR removes the array type declaration on the InteractsWithViews concern used in testing. These methods should ultimately have the type declaration of Arrayable|array, but until the framework's minimum PHP version is increased to 8, the type declaration should be removed.

With this array type declaration, one must explicitly call ->toArray() on any Arrayable they are using, otherwise a TypeError is thrown: TypeError : Illuminate\Foundation\Testing\TestCase::view(): Argument #2 ($data) must be of type array, ...

public function test_view()
{
    $arrayable = new SomeArrayable();
    $this->view('post.form', $arrayable->toArray());
}
public function test_view()
{
    $arrayable = new SomeArrayable();
    $this->view('post.form', $arrayable);
}

@driesvints driesvints changed the title Fixes restrictive type declaration in InteractsWithViews testing concern 9.x] Fixes restrictive type declaration in InteractsWithViews testing concern Mar 12, 2021
@driesvints driesvints changed the title 9.x] Fixes restrictive type declaration in InteractsWithViews testing concern [9.x] Fixes restrictive type declaration in InteractsWithViews testing concern Mar 12, 2021
@taylorotwell taylorotwell merged commit 3aabbb7 into laravel:master Mar 12, 2021
@rbarden
Copy link
Contributor Author

rbarden commented Jul 7, 2021

@taylorotwell Since Laravel 9.0 will now require PHP 8, do you want me to go ahead and update this PR to use the Arrayable|array type declaration instead of removing it entirely?

@rbarden
Copy link
Contributor Author

rbarden commented Sep 16, 2021

@driesvints What are your thoughts on my question above? I'd be happy to add in the proper types now since laravel 9 is going to use php 8 and union types are allowed. I could update this PR or open a new one.

@driesvints
Copy link
Member

Hey @rbarden. Not for now, thanks.

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.

3 participants