Add default (empty) arguments to renderers.

This commit is contained in:
Madeorsk 2024-11-08 18:25:52 +01:00
parent 35418919ed
commit 596af225e5
Signed by: Madeorsk
GPG key ID: 677E51CA765BB79F
3 changed files with 3 additions and 3 deletions

View file

@ -16,7 +16,7 @@ class PhpRenderer implements Renderer
/**
* @inheritDoc
*/
public function render(object $arguments): string
public function render(object $arguments = new \stdClass()): string
{
// Extract render arguments.
extract((array) $arguments);

View file

@ -12,5 +12,5 @@ interface Renderer
* @param object $arguments View arguments.
* @return string Produced view.
*/
function render(object $arguments): string;
function render(object $arguments = new \stdClass()): string;
}

View file

@ -98,7 +98,7 @@ abstract class Controller
* @param string|null $contentType The content type of the response.
* @return ResponseInterface Built response.
*/
public function render(Renderer $renderer, object $arguments, StatusCode $statusCode = StatusCode::OK, ?string $contentType = null): ResponseInterface
public function render(Renderer $renderer, object $arguments = new \stdClass(), StatusCode $statusCode = StatusCode::OK, ?string $contentType = null): ResponseInterface
{
return $this->newResponse($statusCode, $contentType ?? null, $renderer->render($arguments));
}