-
Notifications
You must be signed in to change notification settings - Fork 14
Extract extra info from headers_sent #13
base: develop
Are you sure you want to change the base?
Conversation
src/Emitter/SapiEmitterTrait.php
Outdated
@@ -31,8 +31,9 @@ trait SapiEmitterTrait | |||
*/ | |||
private function assertNoPreviousOutput() | |||
{ | |||
if (headers_sent()) { | |||
throw EmitterException::forHeadersSent(); | |||
$file = $line = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define on separate lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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