Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Requires `innmind/filesystem:~8.0`
- Requires `innmind/time-continuum:~4.1`
- Requires `innmind/io:~3.0`
- `Innmind\Http\Sender::__invoke()` now returns `Innmind\Immutable\Attempt<Innmind\Immutable\SideEffect>`

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "~8.2",
"innmind/url": "~4.0",
"innmind/immutable": "~5.7",
"innmind/immutable": "~5.11",
"innmind/filesystem": "~8.0",
"innmind/io": "^3.0.1",
"innmind/time-continuum": "~4.1",
Expand Down
10 changes: 8 additions & 2 deletions src/ResponseSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
Exception\LogicException,
};
use Innmind\TimeContinuum\Clock;
use Innmind\Immutable\{
Attempt,
SideEffect,
};

final class ResponseSender implements Sender
{
Expand All @@ -23,10 +27,10 @@ public function __construct(Clock $clock)
}

#[\Override]
public function __invoke(Response $response): void
public function __invoke(Response $response): Attempt
{
if (\headers_sent()) {
throw new LogicException('Headers already sent');
return Attempt::error(new LogicException('Headers already sent'));
}

\header(
Expand Down Expand Up @@ -69,6 +73,8 @@ public function __invoke(Response $response): void
if (\function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}

return Attempt::result(SideEffect::identity());
}

private function sendCookie(SetCookie $cookie): void
Expand Down
10 changes: 9 additions & 1 deletion src/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

namespace Innmind\Http;

use Innmind\Immutable\{
Attempt,
SideEffect,
};

interface Sender
{
public function __invoke(Response $response): void;
/**
* @return Attempt<SideEffect>
*/
public function __invoke(Response $response): Attempt;
}