Extract extra info from headers_sent#13
Extract extra info from headers_sent#13undercloud wants to merge 19 commits intozendframework:developfrom
Conversation
src/Emitter/SapiEmitterTrait.php
Outdated
| { | ||
| if (headers_sent()) { | ||
| throw EmitterException::forHeadersSent(); | ||
| $file = $line = null; |
There was a problem hiding this comment.
I think what you need ... if not, please specify
|
@undercloud It is a new feature, please target develop branch. Also it needs tests to be accepted. |
| ob_get_clean(); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Try it like this:
$this->expectException(EmitterException::class);
$this->expectExceptionMessage('Unable to emit response; headers already sent');
$this->expectExceptionMessage(sprintf(
'output started at %s:%d',
__FILE__,
__LINE__ + 3
));
ob_start();
echo 'Unexpected Output';
try {
$this->emitter->emit($response);
} catch (\Throwable $e) {
throw $e;
} finally {
ob_end_clean();
}There was a problem hiding this comment.
Unfortunately, unsuccessfully ... I assume that sending headers is not called in the SAPI environment of tests, all my attempts at tests are unsuccessful ...
|
This repository has been closed and moved to laminas/laminas-httphandlerrunner; a new issue has been opened at laminas/laminas-httphandlerrunner#1. |
|
This repository has been moved to laminas/laminas-httphandlerrunner. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
headers_sent allows you to define a file and a line that has undesirable output, otherwise it is impossible to identify and correct the error, there is not enough of this and it is difficult to debug, but the edit is very small, but gives many possibilities, I hope this edit will fall into the main branch, thanks!
https://www.php.net/manual/en/function.headers-sent.php