From 596af225e592a99ab6d02c419860cedc5949b701 Mon Sep 17 00:00:00 2001 From: Madeorsk Date: Fri, 8 Nov 2024 18:25:52 +0100 Subject: [PATCH] Add default (empty) arguments to renderers. --- src/Renderer/PhpRenderer.php | 2 +- src/Renderer/Renderer.php | 2 +- src/Router/Controller.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Renderer/PhpRenderer.php b/src/Renderer/PhpRenderer.php index 7713049..abccaba 100644 --- a/src/Renderer/PhpRenderer.php +++ b/src/Renderer/PhpRenderer.php @@ -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); diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 5c38daf..cafa5b3 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -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; } diff --git a/src/Router/Controller.php b/src/Router/Controller.php index 9b16945..a99c4b6 100644 --- a/src/Router/Controller.php +++ b/src/Router/Controller.php @@ -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)); }