Skip to content

Commit c6a747d

Browse files
committed
minor symfony#38403 Remove array return type from Request::toArray() (GrahamCampbell)
This PR was merged into the 5.2-dev branch. Discussion ---------- Remove array return type from Request::toArray() | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix symfony#38400 | License | MIT | Doc PR | - Laravel already extends Symfony's `Request` class and defines it's own `toArray` method. symfony#38224 added a new `toArray` method to this class with a different signature to the one that is in Laravel, causing fatal errors (laravel/framework#34660). I think the best course of action here is to remove the return type for now, and only add it in Symfony 6. This will allow Symfony 6.0 and Laravel 11 to synchronize adding the return type. Older versions of Laravel can't just change their signature to add an array return type to them, because that would be a breaking change for Laravel users extending Laravel's request class. I'm thinking, in particular, API packages and the like, or just straight up application code. Commits ------- 8b291a4 Remove array return type from Request::toArray()
2 parents 200392e + 8b291a4 commit c6a747d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,10 @@ public function getContent(bool $asResource = false)
15741574
* Gets the request body decoded as array, typically from a JSON payload.
15751575
*
15761576
* @throws JsonException When the body cannot be decoded to an array
1577+
*
1578+
* @return array
15771579
*/
1578-
public function toArray(): array
1580+
public function toArray()
15791581
{
15801582
if ('' === $content = $this->getContent()) {
15811583
throw new JsonException('Response body is empty.');

0 commit comments

Comments
 (0)