Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 98f297e

Browse files
committed
Emitters should return boolean
This will allow us to address the issues with overloading the return value in order to accommodate the `EmitterStack`.
1 parent 12264d5 commit 98f297e

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/Emitter/EmitterInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ interface EmitterInterface
2525
*
2626
* Implementations MAY raise exceptions if they are unable to emit the
2727
* response; e.g., if headers have already been sent.
28+
*
29+
* Implementations MUST return a boolean. A boolean `true` indicates that
30+
* the emitter was able to emit the response, while `false` indicates
31+
* it was not.
2832
*/
29-
public function emit(ResponseInterface $response) : void;
33+
public function emit(ResponseInterface $response) : bool;
3034
}

src/Emitter/SapiEmitter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ class SapiEmitter implements EmitterInterface
2121
* Emits the status line and headers via the header() function, and the
2222
* body content via the output buffer.
2323
*/
24-
public function emit(ResponseInterface $response) : void
24+
public function emit(ResponseInterface $response) : bool
2525
{
2626
$this->assertNoPreviousOutput();
2727

2828
$this->emitHeaders($response);
2929
$this->emitStatusLine($response);
3030
$this->emitBody($response);
31+
32+
return true;
3133
}
3234

3335
/**

src/Emitter/SapiStreamEmitter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SapiStreamEmitter implements EmitterInterface
2323
*
2424
* @param int $maxBufferLength Maximum output buffering size for each iteration
2525
*/
26-
public function emit(ResponseInterface $response, int $maxBufferLength = 8192) : void
26+
public function emit(ResponseInterface $response, int $maxBufferLength = 8192) : bool
2727
{
2828
$this->assertNoPreviousOutput();
2929
$this->emitHeaders($response);
@@ -33,10 +33,11 @@ public function emit(ResponseInterface $response, int $maxBufferLength = 8192) :
3333

3434
if (is_array($range) && $range[0] === 'bytes') {
3535
$this->emitBodyRange($range, $response, $maxBufferLength);
36-
return;
36+
return true;
3737
}
3838

3939
$this->emitBody($response, $maxBufferLength);
40+
return true;
4041
}
4142

4243
/**

0 commit comments

Comments
 (0)