Skip to content

Commit

Permalink
Enforce response type
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed May 30, 2024
1 parent 86e820e commit a09401c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/mako/http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use mako\http\response\senders\ResponseSenderInterface;
use mako\http\response\Status;
use mako\security\Signer;
use Stringable;

use function hash;
use function header;
Expand Down Expand Up @@ -98,7 +99,7 @@ public function getRequest(): Request
/**
* Sets the response body.
*/
public function setBody(mixed $body): Response
public function setBody(ResponseBuilderInterface|ResponseSenderInterface|string|Stringable $body): Response
{
$this->body = $body;

Expand Down
8 changes: 7 additions & 1 deletion tests/unit/http/routing/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@
use mako\syringe\Container;
use mako\tests\TestCase;
use Mockery;
use Stringable;

// --------------------------------------------------------------------------
// START CLASSES
// --------------------------------------------------------------------------

class InjectMe
class InjectMe implements Stringable
{
public function helloWorld()
{
return 'Hello, world!';
}

public function __toString()
{
return $this->helloWorld();
}
}

class SimpleController extends Controller
Expand Down

0 comments on commit a09401c

Please sign in to comment.