Fr3nch13/CakePHP Utilities

SapiStreamEmitter
in package
implements EmitterInterface uses SapiEmitterTrait

Tags
psalm-type

ParsedRangeType = array{0:string,1:int,2:int,3:'*'|int}

Table of Contents

Interfaces

EmitterInterface

Properties

$maxBufferLength  : int

Methods

__construct()  : mixed
emit()  : bool
Emits a response for a PHP SAPI environment.
assertNoPreviousOutput()  : void
Checks to see if content has previously been sent.
emitBody()  : void
Emit the message body.
emitBodyRange()  : void
Emit a range of the message body.
emitHeaders()  : void
Emit response headers.
emitStatusLine()  : void
Emit the status line.
filterHeader()  : string
Filter a header name to wordcase
header()  : void
headersSent()  : bool
parseContentRange()  : null|array<string|int, mixed>
Parse content-range header http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16

Properties

Methods

__construct()

public __construct([int $maxBufferLength = 8192 ]) : mixed
Parameters
$maxBufferLength : int = 8192

emit()

Emits a response for a PHP SAPI environment.

public emit(ResponseInterface $response) : bool

Emits the status line and headers via the header() function, and the body content via the output buffer.

Parameters
$response : ResponseInterface
Return values
bool

assertNoPreviousOutput()

Checks to see if content has previously been sent.

private assertNoPreviousOutput() : void

If either headers have been sent or the output buffer contains content, raises an exception.

Tags
throws
EmitterException

If headers have already been sent.

throws
EmitterException

If output is present in the output buffer.

emitBodyRange()

Emit a range of the message body.

private emitBodyRange(array<string|int, mixed> $range, ResponseInterface $response) : void
Parameters
$range : array<string|int, mixed>
$response : ResponseInterface
Tags
psalm-param

ParsedRangeType $range

emitHeaders()

Emit response headers.

private emitHeaders(ResponseInterface $response) : void

Loops through each header, emitting each; if the header value is an array with multiple values, ensures that each is sent in such a way as to create aggregate headers (instead of replace the previous).

Parameters
$response : ResponseInterface

emitStatusLine()

Emit the status line.

private emitStatusLine(ResponseInterface $response) : void

Emits the status line using the protocol version and status code from the response; if a reason phrase is available, it, too, is emitted.

It is important to mention that this method should be called after emitHeaders() in order to prevent PHP from changing the status code of the emitted response.

Parameters
$response : ResponseInterface
Tags
see
SapiEmitterTrait::emitHeaders()

filterHeader()

Filter a header name to wordcase

private filterHeader(string $header) : string
Parameters
$header : string
Return values
string

header()

private header(string $headerName, bool $replace, int $statusCode) : void
Parameters
$headerName : string
$replace : bool
$statusCode : int

headersSent()

private headersSent([string|null &$filename = null ][, int|null &$line = null ]) : bool
Parameters
$filename : string|null = null
$line : int|null = null
Return values
bool

parseContentRange()

Parse content-range header http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16

private parseContentRange(string $header) : null|array<string|int, mixed>
Parameters
$header : string
Tags
psalm-return

null|ParsedRangeType

Return values
null|array<string|int, mixed>

[unit, first, last, length]; returns null if no content range or an invalid content range is provided


        
On this page

Search results